Setting up forFeature() from string to selection function

We can set it up in pretty much the same way, but we need to pass it the name of a feature as well. Let's take our counter.module.ts and add a little code to it:

// counter.module.ts@NgModule({  imports: [    StoreModule.forFeature('counter',{      data: counterReducer        })  ]})

This will change how we select our state, though. Imagine we are inside of counter.component.ts with the current implementation looking like the following:

// counter.component.ts@Component({  selector: 'counter',  template: `{{ counter$ | async }}`})export class CounterComponent {  counter$;  constructor(private store: Store<AppState>) {    // this needs to change..    this.counter$ = this.store.select('counter');  }}

Because we ...

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.