Want to implement shared store module for sharing state between 2 feature modules Can some one please share stackblitz or git repo link for shared state module
Asked
Active
Viewed 1,116 times
2
-
I would recommend to have them as a `rootStore` in the `AppModule` directly, – Aravind Apr 24 '20 at 06:52
-
I am in the process of modularizing the application by having lazy routes and separate feature stores. But we have multiple scenarios where one feature has some state dependency on other feature..so if i keep shared state in the rootStore in appModule , wouldn't it have a performance impact? – Naina Apr 24 '20 at 07:00
-
okay! make sense. so you want to share store between 2 or more features stores is that. So I would recommend to create a shared module between these features and put your store in it – Aravind Apr 24 '20 at 16:44
1 Answers
0
the store is accessible by all imported modules of a module that imports StoreModule.forRoot
.
Therefore if you have StoreModule.forRoot
in your AppModule
, then any lazyloaded module can perform this.store.select(SELECTOR)
or this.store.dispatch(ACTION)
and it will return data and cause changes as you expect.

satanTime
- 12,631
- 1
- 25
- 73