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

Move store state outside of context and force updates to subscribed components externally #7

Closed
Jahans3 opened this issue Nov 21, 2019 · 1 comment

Comments

@Jahans3
Copy link
Owner

Jahans3 commented Nov 21, 2019

This library already borrows heavily from the Redux API that many are familiar with, so in order to get our main hook working as intended (enable partially subscribing to state updates) we may as well borrow some more ideas.

Some key points:

  • State will live outside the component hierarchy
  • Context will hold a constant reference to the store - the actual context value will be static
  • Internally, we will move to a pub/sub architecture
  • Subscribers will be forced to re-render from an external subscription - we can enable this by passing a setState to each subscription

The external API should not change and everything should remain simple and quick to setup, meaning store creation should still involve nothing more than passing a reducers prop to our provider.

@Jahans3
Copy link
Owner Author

Jahans3 commented Jan 26, 2021

After a long wait this will soon be possible with the introduction of React.useContextSelector

@Jahans3 Jahans3 closed this as completed Jan 26, 2021
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

1 participant