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

Support for hierarcical local stores. #18

Open
gaperton opened this issue Oct 4, 2016 · 1 comment
Open

Support for hierarcical local stores. #18

gaperton opened this issue Oct 4, 2016 · 1 comment

Comments

@gaperton
Copy link

gaperton commented Oct 4, 2016

Since we're finally moving to hierarchical stores architecture, we need to implement support for it in React components (one main global shared store + may be some other stores shared across the pages +local store for each app page extending the main one). We need several things.

  1. There's the root component for an application page. The lifecycle of the page local store is really bound to its presence in DOM. Therefore, we either need to declare the store at the component itself or provide it with a reference to existing one. In the first case, it would be beneficial if the component would completely manage the store lifecycle, including I/O (not rendered until I/O is completed).

It's probably the good idea to wrap store management to the separate component. When it's mounted, it fetches itself.

Consider making this component generally I/O aware (capable of simple REST stuff and accepting an I/O promises). That will reduce latency in case of the root page.

  1. Nested Store components must process chained store lookups.

  2. Think what to do whenever store items are updated. Should the component tree be updated too?
    Should be not worse than dealing with root state. There might be an issue with pureRender, though (it will ignore store updates). Also, there might be an issue with tracking of updates across store hierarchy (should we really track changes for all the store chain items?).

Alternative is to provide the list of the store elements to access and track the changes in.

@gaperton gaperton changed the title Support for hieracical local stores. Support for hierarcical local stores. Oct 4, 2016
@gaperton
Copy link
Author

Alternative proposals.

  1. Use store declaration instead of state. It should define the model extending Store, which is integrated into dynamic store lookup chain across the UI components tree. In this case:
  • root component have to pass store elements down explicitly
  • children state might rely on the references to the store elements
  • children actually can access parent store using the getStore() locator. The thingy works as an alternative to the context. Allows potentially dangerous programming style.

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

No branches or pull requests

1 participant