Following is my angular app structure
app.module.ts
-- StoreModule.forRoot()
mainboard.module.ts
--StoreModule.forFeature('mainboard', reducer)
subFeature1.module.ts
subFeature2.module.ts
subFeature3.module.ts
dashboard1.module.ts
--StoreModule.forFeature('dashboard1', reducer)
subFeature1.module.ts
subFeature2.module.ts
subFeature3.module.ts
subFeature4.module.ts
subFeature5.module.ts
dashboard2.module.ts
--StoreModule.forFeature('dashboard2', reducer)
subFeature1.module.ts
subFeature2.module.ts
dashboard3.module.ts
--StoreModule.forFeature('dashboard3', reducer)
subFeature1.module.ts
subFeature2.module.ts
subFeature3.module.ts
subFeature4.module.ts
dashboard4.module.ts
--StoreModule.forFeature('dashboard4', reducer)
subFeature1.module.ts
subFeature2.module.ts
So the requirement is to have store for subfeatures.
Like this:
app.module.ts
-- StoreModule.forRoot()
mainboard.module.ts
--StoreModule.forFeature('mainboard', reducer)
subFeature1.module.ts
--StoreModule.forFeature('subFeature1', reducer)
subFeature2.module.ts
--StoreModule.forFeature('subFeature1', reducer)
subFeature3.module.ts
--StoreModule.forFeature('subFeature1', reducer)
...
HOW CAN I ACHIEIVE SUCH A HIERARCHY FOR MY NGRX/STORE ?
app.module is there all the dashboards are placed.
dashboard-x.modules are the places where all the navs/ items are placed.
and inside each dashboards sub features are included.
So my question is about how to register subFeatures with StoreModule.forFeature()?
Or do I need to make stores for each dashboards (StoreModule.forRoot()) and then StoreModule.forFeature() for each subFeatures? (if so then how may I be able to register it inside the app's StoreModule.forRoot())
NOTE
Currently I'm registering all of the subfeatures as forFeature.('subfeturename', reducer)
But the problem with this is that when I have a look at my state tree (Redux devtools) it is not following the above store tree structure. Since all the sub features are getting registered as forFeature() all of them are showing as properties (ie, they are not getting nested as expected). What I want instead is that I want to have them nested inside my state tree.
So if I have a look at my state tree I can see nested state Like this:
app
mainboard(open)
subFeature1
subFeature2
subFeature3
dashboard1(closed)
dashboard2(open)
subFeature1
subFeature2
dashboard3(closed)
dashboard4(closed)
//open and closed means expand and collapsed tree
Remember, each level (app > dashboard1 > subfeature) has different properties which needs to be managed by stores. So a store is necessary for each level.