mrpmorris / Fluxor

Fluxor is a zero boilerplate Flux/Redux library for Microsoft .NET and Blazor.
MIT License
1.24k stars 141 forks source link

Dispatching before store has been initialised results in lost actions #301

Closed mrpmorris closed 2 years ago

mrpmorris commented 2 years ago

When dispatching an action from App.Razor without injecting IStore the action will be broadcast from IDispatcher to observers before the store has been created to subscribe and react.

Although this approach should ideally be implemented as an [Effect] for StoreInitializedAction it is still not right that these actions silently disappear.

Suggestion: Throw an InvalidOperationException if IDispatcher.Dispatch is executed when there are no subscribers, with a message telling the user they should not dispatch actions before the store has been initialised.

Changes should be based on branch release/5.4

mrpmorris commented 2 years ago

Approach taken was to queue actions in Dispatcher whenever it has no subscriber, and that queue is emptied once a subscriber is added.

mrpmorris commented 2 years ago

Release 5.4