Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mrpmorris opened this issue May 8, 2022 · 2 comments
Closed
Labels
good first issue Good for newcomers
Milestone

Comments

@mrpmorris
Copy link
Owner

mrpmorris commented May 8, 2022

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 mrpmorris added this to the 5.4 milestone May 8, 2022
@mrpmorris mrpmorris added the good first issue Good for newcomers label May 8, 2022
@mrpmorris
Copy link
Owner Author

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

@mrpmorris mrpmorris mentioned this issue May 17, 2022
mrpmorris added a commit that referenced this issue May 17, 2022
 * ActionSubscribers are now notified after state has been reduced ([#299](#299))
 * Routing middleware will no longer dispatch a GoAction when URl is the same value but formatted differently ([#297](#297))
 * `IDispatcher` now queues actions whenever there are no subscribers to the `ActionDispatched` event and then
   dequeues them when a subscriber is added ([#301](#301))
@mrpmorris
Copy link
Owner Author

Release 5.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant