The reason for wanting only part of the state is that we will use NgRx in a context where there will be many components that only care about rendering a little part of the application's full state. For example, we may have a product list component, a product detail component, and so on. For that reason, we need to implement support for getting a slice of state. Thanks to the fact that our store inherits from a BehaviorSubject, implementing a slice of state is child's play:
// NGRX-light/storeVII.jsconst Rx = require('rxjs');function counterReducer(state = 0, action) { switch(action.type) { case "INCREMENT": return state + 1; default: return state; }}function productsReducer(state = [], action) { switch(action.type) ...