Iterate over list of filtered items? #212
-
I wrote a thing to stream a set of github workflow results down to a React frontend. The observable is like so:
Where the languages are a list of the languages I've seen so far. Now, on display, I want to iterate over the languages (easy to use For for this), and then display a little div-based card of the results filtered by the language. How do I do that interior filter? I tried passing a filtered list to a For on the inner, but it didn't like that. I have:
But I assume that is wrong because there's a lot of peeking which likely means I am not reacting properly to changes. How would I do this properly? I know I could maintain the pre-filtered list and just update that every time a new result is loaded, but that seems a little overwraught. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
I would probably do it with a computed of the filtered list, and pass that into For. But your approach should work just fine - if you change Benefits of each approach:
But in practice there's not really any meaningful difference. Just do what feels better. |
Beta Was this translation helpful? Give feedback.
-
And on the existing one, you're saying that this is reactive to new entries to the results:
|
Beta Was this translation helpful? Give feedback.
I would probably do it with a computed of the filtered list, and pass that into For. But your approach should work just fine - if you change
language.peek()
tolanguage.get()
it'll be reactive. If you want to overoptimize it (which probably isn't necessary) you you could mover.language.get()
out to local state.Benefits of each approach:
optimized
mode is a goo…