DEV Community

NgRx — Best Practices for Enterprise Angular Applications

Wes on February 04, 2019

Before We Get Started This article is not intended to be a tutorial on NgRx. There are several great resources that currently exist, wri...
Collapse
 
dlucazeau profile image
Daniel Lucazeau

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

Collapse
 
wesgrimes profile image
Wes Angular

Great Question Daniel! You should be able to dispatch actions in other features from effects. Is this not working?

Collapse
 
dlucazeau profile image
Daniel Lucazeau

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 ?

Thread Thread
 
wesgrimes profile image
Wes Angular

Can you show me how you're importing the ItsmStoreActions? Like what does you ts import statement look like?

Thread Thread
 
wesgrimes profile image
Wes Angular

If you can, post a repo on stackblitz or github recreating the issue. Then we can resolve together. Thanks!!

Thread Thread
 
dlucazeau profile image
Daniel Lucazeau • Edited

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 ?