Multiple ngrx stores in one app

We are the developers of a large Angular application module. Modules are independent of each other, they are developed by separate teams. We want to use ngrx storage in our module.

Another module already has ngrx storage. If I try to add a store to our module.ts in the usual way:

@NgModule({
  imports: [
    ...
    StoreModule.provideStore( ... )
  ],
  ...

It crashes the entire application. Is there a way to provide a separate store for our module?

(application uses ngrx2)

+4
source share
2 answers

You can split the storage, for one you can have a basic storage for loading with the application module at startup using forRoot, also adding metaReducers and initialState to it

StoreModule.forRoot(reducers, {metaReducers: metaReducers, initialState: getInitialState})

,

StoreModule.forFeature('gallery', reducers, {initialState: getGalleryInitialState})

- 4, , 2 , , ,

+1

ramon22, .

T featureState - , .

0

Source: https://habr.com/ru/post/1687069/


All Articles