-
Notifications
You must be signed in to change notification settings - Fork 311
WIP: Provide fractal state management #269
WIP: Provide fractal state management #269
Conversation
Todo:
|
I would like to pick up on docs again / start updating older examples as time allows. Maybe we can discuss long term plans for docs soon and begin filling in the gaps at high priority areas. Really excellent work on this PR! |
this looks good to me - when you're happy with it lets merge and tag a v3.0.0 beta? |
Is this something that would work with Lazy-loaded Modules as well? 👍 @MikeRyan52 @robwormald |
@MikeRyan52 Is there any estimate as of when this feature gets into mainline? |
What is the status of this? Is there a remaining task list? Can we help somehow? |
Hey guys, Works great on my project. Thanks a lot ! |
e08f3ca
to
835bdb5
Compare
Update on this merge request:
|
+1 for asking for docs on the new features and how to migrate, tx!!!! Sean |
835bdb5
to
684d04b
Compare
684d04b
to
8c392cf
Compare
Updated to Angular 4 RC 1 and got the tests to pass. cc @robwormald |
8c392cf
to
98d283b
Compare
any plans to make a conversion document and detail instructions on how the implementation differs now? |
@born2net Yes, definitely. The current plan (as far as I am aware) is to rollout v4 of all ngrx projects at once with updated documentation. |
awesome, as I for one, am really not sure what the changes are and the ramifications for existing projects, TX! |
Cheers Mike, I'll merge this as the final commit on this repo 😲
…On Mon, Feb 27, 2017 at 10:50 AM Mike Ryan ***@***.***> wrote:
@born2net <https://github.com/born2net> Yes, definitely. The current plan
(as far as I am aware) is to rollout v4 of all ngrx projects at once with
updated documentation.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#269 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAgpkndB2jZfHIVSctnK2PjzkIA-At-vks5rgxr_gaJpZM4Ku_h6>
.
|
Could you guys elaborate on the thought behind eliminating scoped stores? Is it just to make it easier for people getting started? I feel like the lack of an easy way to scope stores can be a huge drawback in larger applications. Essentially it forces feature modules (as they are called in this PR) to know exactly where they live in the global state tree which breaks encapsulation. I'd like to mount a feature module into the main store, and have everything related to that module (reducers, state, actions, selectors) automatically scoped so that the module doesn't need to know about anything outside of it. Something like this could be used to deal with actions and reducers: https://medium.com/@insideout.develop/how-to-scale-a-redux-application-with-redux-action-recompose-d836ba27776b#.3ff8u3okg However, selectors still need to know where in the global state tree they should go look for the required state. If the store was scoped, they would only need to know about the slice of the state that concerns that specific feature module. |
@hccampos Sure! The decision to eliminate scoped instances of Instead, we have opted to let the features determine where they live in the global state tree by providing their name: StoreModule.forFeature('featureName', { blog: blogReducer }) This will produce a global state tree that looks like this: {
featureName: {
blog: BlogState
}
} We plan on suggesting a naming convention to help prevent naming collisions. For instance, you can expect @ngrx/store to install itself like this: {
'@ngrx/store': {
router: RouterStateSnapshot;
}
} What's great is that the library can strongly type the shape of the global state tree: interface RootState {
['@ngrx/router-store']: { router: RouterStateSnapshot };
} |
Actually, i mostly agree with @hccampos here. I think the namespaced state thing is a nice optional feature, but i'm not convinced that's the right solution by default. I've been prototyping from my end using the injectors to define hierarchy, following the mechanism of the router. This enforces the same kind of visibility scoping as the router, and you end up with a more "extends" type functionality:
would expose a computed state of
This means:
Benefits:
|
@robwormald I would very reluctant of moving away from a single state object. It provides a clean state rehydration story and makes it easy to integrate with the existing Redux devtools. Additionally, polluting a global state object doesn't seem so bad since we can check for collisions with typings. |
I agree with the single global state object at the top. That would indeed make serialization and rehydration easier. However, the child stores themselves need to be scoped so that To avoid confusion about which store you have in a certain place, you could have two injectable stores per lazy module, the Imho, it would go right in line with the hierarchical structure of Angular's injectors. I do agree, nevertheless, that it would probably be better if this could be an optional feature so that people don't have to deal with it in simpler apps, examples, etc. |
My two cents is that it's perfect the way it is today and I hope whatever you do moving forward, that it will be backward-compatible. if it ain't broken why fix it and I don't think it's broken right now... |
Just leaving this for reference here: https://github.com/salsita/prism The way they scope the redux store so that each component "instance" only sees what concers it is similar to what could be achieved via Angular's hierarchical injectors. |
Isn't this now going back to the flux architecture of multi-store? |
@born2net nope, still single store, but with projections of the store for different components/modules. It is how Elm works (Prism used to be called redux-elm) and it is imho, the most elegant solution for large applications. As it stands, if you move a module around, you have to also go and update the selector used to get its slice. And if you want to have two instances of a component with the same reducer chaos ensues and you need to bring in ids, duplicate actions, selectors and reducers. |
ok thanks for the explanation, but what do you mean "if you move a module around"? |
@hccampos I agreed, right now using multiple components with the same reducer is way too much of a hassle. |
I'm gonna go ahead and merge this, so we can move forward with porting ngrx into the new monorepo. I'm still up in the air about it, but i'd rather land this and let people experiment with it. |
Interesting idea over in the mobx universe https://github.com/mobxjs/mobx-state-tree |
@robwormald: Could you explain more about "porting ngrx into the new monorepo"? Also, is there a document or post about the general ngrx roadmap, plans, ideas etc? |
Any ETA on some basic docs? Would love to start experimenting with this, but not sure how to yet. |
@MikeRyan52 Is there any plan to release fractal state management with @angular/[email protected] and [email protected]? |
i need some help regarding ngrx/store fractal state management |
So is it safe to say we just have to wait for the v3 release coming from the new monorepo to use this? What are the plans here? Wouldn't it be good to get community feedback so it can be improved (if necessary) for the next release? |
@ngFor Yes, you have to wait for the monorepo to stabilize. Getting Store working with fractal state was only part of the challenge. Now we are working on router-store, store-devtools, and effects. Once everything is ready to go we will distribute an alpha version of v4. We'll gather community feedback and shape a final release for (hopefully) May. |
This reverts commit 32c0fe0.
This reverts commit 32c0fe0. This keeps this repo at version 2.x so we can keep the docs current and the monorepo will move forward with V4
This reverts commit 32c0fe0.
Is there any update on this? Should we use ngrx/platform nightly? |
@marcguilera Yes, use ngrx/platform nightly builds. There are docs in the new repo explaining how. If you're using angular-cli, make sure you use one of the newest versions that has typescript 2.3 support. |
The angular-cli now supports typescript 2.3, any update on when this might be released? |
This is a WIP implementation of #211
Key features: