getReducer
Generate the reducer function
From a facade all case-reducers are extracted and combined into a single reducer function by using getReducer
.
Since a reducer expects an initial state, getReducer
needs the initial state to be passed as well as the class token of the respective facade.
The generated reducer can then be registered in NgRx's action reducer map (see index.ts
).
Please refer to the demo on StackBlitz to see a full example.
Inlining
You also can inline getReducer
in your Facade holding everything together. It's up to you which style you prefer. The benefit of inlining is, that the Facade becomes the only thing you import somewhere else.
Last updated