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

Best pattern for nested components #2

Open
rkpatel33 opened this issue Oct 20, 2017 · 0 comments
Open

Best pattern for nested components #2

rkpatel33 opened this issue Oct 20, 2017 · 0 comments

Comments

@rkpatel33
Copy link

rkpatel33 commented Oct 20, 2017

Thanks for this library and the posting Dissection of Flux architecture or how to write your own, it was very helpful.

I am considering using Fluxiny for a project that uses Electron + React. This is my first project that uses React and flux, so I wanted to confirm something before getting going on refactoring to use Fluxiny.

If one has many levels of component nesting, in order to make the store available to child components, it seems like the pattern you have to follow is:

  • import the store in question, say AppDataStore.js at the entry point the creates the root React component
  • create a subscriber function with something like let subscriber = createSubscriber(AppDataStore)
  • then keep passing subscriber function down the component hierarchy as a prop function so each component can subscribe to the store as needed by that component.

Is this correct? I guess the other option might be to:

const { createSubscriber, createAction } = Fluxiny.create();

Inside each react component module, but looking at the code seems like this will instantiate a completely new Fluxiny dispatcher behind the scenes.

Thanks.

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