"any()" equivalent in a state var? #3815
-
Hi there, I've been struggling with trying to find out if any value inside a list state var matches a condition. My state has a list of objects (broadcasters) with a name. The same state also has a list of paths, I now want to check for each path if any of the broadcasters names is contained within it. So for instance: rx.foreach(
MyState.Paths,
lambda path: any(broadcaster.name in path.source for broadcaster in MyState.Broadcasters)
), The result of this will then be assigned to the rx.switch(
checked=MyState.has_broadcaster(row),
), Is there an elegant way to achieve this? Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
you could use a cached computed var that computed a dictionary for each row and then index into that dictionary by row id or similar identifier |
Beta Was this translation helpful? Give feedback.
you could use a cached computed var that computed a dictionary for each row and then index into that dictionary by row id or similar identifier