Best way to subscribe to multiple states / mimic RxJS combineLatest #441
Replies: 3 comments 1 reply
-
I'm finding it difficult to understand fully what you mean. If your app fires off an action to change the filter or the elements in the state, you could have a complete list + a filtered list, and the filtered list would only show fullList.Where(x => filter.Matches(x)); If you want that done in your component instead, you could re-filter the list each time the state changes. You can do this by injecting IState and manually subscribing to the StateChanged event on it - but remember to override Dispose and unsubscribe. Does that help? |
Beta Was this translation helpful? Give feedback.
-
Hi mrpmorris, thanks for replying! I should have pointed out better that the question is about multiple states, let's say 3 states. I want to act based on every of the 3 states, when any of these changes. With RxJs, it works like this (pseudocode):
This is exactly what StateSubscriber does, which is used in Fluxor Component. Would it be suitable to use the StateSubscriber in my code? Best Chris |
Beta Was this translation helpful? Give feedback.
-
I wonder if you might be able to use https://github.com/mrpmorris/Cascade/blob/master/Source/Morris.Cascade/CombinedSource.cs in some way? I've not given any thought to making Fluxor like RxJS |
Beta Was this translation helpful? Give feedback.
-
Hi there,
let's assume there are multiple relevant states in a component, e.g. a list of entities (products If you will) and a separate filter.
What is the best way to apply the filter when the filter itself changed or if the list of entities changed?
StateSubscriber
likeFluxorComponent
doesThe
FluxorComponent
is really doing exactly this, but only to callStateHasChanged
. Unfortunately I don't see a Blazor lifecycle hook likeOnBeforeRender
, which would be perfect for this situation.Are there any opinions?
I am trying to get the functionality of a combineLatest in the RxJs world.
All the best
Chris
Beta Was this translation helpful? Give feedback.
All reactions