Going from forRoot() to forFeature()

To solve the mess we are creating in app.module.ts, we will now use a method called forFeature() on StoreModule that will allow us to set up the states we need per feature module. Let's take the existing setup and refactor that:

// app.module.tsStoreModule.forRoot({  }) // this would be empty

We move our two reducer entries to their respective feature modules, counter.module.ts and jedi.module.ts. That would now look like this:

// counter.module.ts@NgModule({  imports: [StoreModule.forFeature(    // add reducer object here  )]})// jedi.module.ts@NgModule({  imports : [StoreModule.forFeature(  // add reducer here  )]})

We left out the implementation on purpose here because we need to take a step back. Remember when ...

Get Architecting Angular Applications with Redux, RxJS, and NgRx now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.