Subscribing external events
alperenbelgic opened this issue · 2 comments
I am considering to propose the library for a project / development team. It's a complex WPF application handling several external hardware resources/sensors and providing visuals / UIs with complex user interactions.
I used the library on multiple Blazor applications before and it worked just perfect.
For this new use case, I am not quite sure how to handle external event subscriptions within Fluxor.
When making HTTP requests on a web app we use effects but I am not sure if I need to make external event subscriptions within UI controls and make action dispatches or if there's any way to keep the life cycle of subscription/unsubscription in effects.
The Fluxor.Blazor.Web library provides FluxorComponent and FluxorLayout which handles updating the UI automatically.
If you do not inherit from FluxorComponent or FluxorLayout in a Blazor application, you need to subscribe to the StateChanged event and update the UI in your code by calling InvokeAsync(StateHasChanged). Also, on disposal of a component you must unsubscribe from the StateChanged event.
The same concept of subscribing / unsubscribing to the StateChanged event can be used with your WPF application.
However your app usually listens for events, just do that. When they happen then dispatch actions with the new data in.
If it's fast paced streaming data then it might be better to use ReactiveX or something. At least worth checking, anyway.