Before We Get Started
This article is not intended to be a tutorial on NgRx. There are several great resources that currently exist, wri...
For further actions, you may consider blocking this person and/or reporting abuse
Hello,
I have two features in my store: Auth and Itsm. After a successful connection with Auth, I want to send the first action of Itsm. But there is a circular dependency.
I think I have built all the stores by following the tutorial. If I use the router directly in Auth-Effects, it works well.
Do you have an example with two features and one calling the second?
Thank you for this tutorial which is what I needed.
Daniel
Great Question Daniel! You should be able to dispatch actions in other features from effects. Is this not working?
Hi
I have built AuthStoreModule and ItsmStoreModule with the same plan - from tutorial.
They are both injected in RootStoreModule.
I get "WARNING in Circular dependency detected:" when in auth-store/effects I want to "this.store.dispatch(new ItsmStoreActions.ItsmBeginLoadingRequests())"
Complete error is
WARNING in Circular dependency detected:
src\app\root-store\root-store.module.ts -> src\app\root-store\auth-store\auth-store.module.ts -> src\app\root-store\auth-store\effects.ts -> src\app\root-store\index.ts -> src\app\root-store\root-store.module.ts
Do I have to manage some high level states directly in root-store ?
Can you show me how you're importing the ItsmStoreActions? Like what does you ts import statement look like?
If you can, post a repo on stackblitz or github recreating the issue. Then we can resolve together. Thanks!!
I have sent a screenshot with organization of files and the code of ItsmActions import.
The import is only in the itsm-store/index.ts ?
you may have to directly import the itsm-store/actions.ts to avoid the duplicate/circular imports. When I get off work I will look into this more.
Thanks for the feedback Daniel! We will get this figured out. And I will add some notes to the article so that others don't stumble on this issue.
I can't publish all the code to a github repo, it's too big. I will build a little appli with the essential of the code.
It's a good idea, so I will test the Store without all the views and the backend.
Great idea. I always try to recreate things in isolated mini repos.
I have forked your project and added a second feature store: hoax ;-)
joke-store/effects can only return action of type koke-actions/actions. So I have imported the main hoax actions and that is running, even if the list of jokes is not proposed.
This is not practical nor clean because I will have about 10-12 main features in the menu after login (AUTH).
With this technique, I need to import all the initial actions of all features into all feature actions. 12 * 12 imports ...
English is not my mother language, I hopeyou understand my explainations.
You can see my changes in github.com/dlucazeau/angular-ngrx-...
I will continue to research this important aspect for our application.
I will go from one menu / item to another directly with the router. And the first step after that will be to activate the feature store. It works well.
As we must be able to install this on-site application with all or only a few features, this architecture will be suitable.
I will study the lazzy loading of the stores.
Your tutorial was a good introduction to solve my problem.
I plan on updating my article soon to accommodate for lazy loading feature stores, I will also address dispatching actions between feature stores
I will monitor and read the news carefully.
Lazy loading is easy, we have just to move the featureModules from AppModule in their corresponding module.
In DevRedux we can see a new line with 'update-reducers'
Agreed.