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

Thread confined dispatch? #12

Closed
AOrobator opened this issue Aug 28, 2019 · 1 comment
Closed

Thread confined dispatch? #12

AOrobator opened this issue Aug 28, 2019 · 1 comment

Comments

@AOrobator
Copy link
Collaborator

Should calls to Store.dispatch be thread confined? Particularly to the main/ui thread of the platform? Dealing with multi-threaded updates to State can get hairy

@patjackson52
Copy link
Contributor

Yes, calls to dispatch should be thread confined. In particular, the reducers need to be executed on the same thread. In my experience the main thread has been used and have not ran into any problems, but an optimal solution may be to do all middleware/reducers off the mainthread, and only updated the UI when subscibers are called.

Yes, enforcing a single/same thread within the library would be good to prevent race conditions. This could be done inside of the dispatch function in createStore

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

No branches or pull requests

2 participants