I have some questions of how individual states for each reducer is sliced.
In a lot of tutorials online (like this one) there is a root global state defined manually that combines all individual states called AppState
.
Is it correct to say that when we pass the object literal that contains all the reducers to StoreModule:
StoreModule.provideStore({r1: ReducerFunc1, r2: ReducerFunc2, ...})
the object keys r1
and r2
can be used to query slices of state when using string selector:
store.select("r1")
However, if we want type safety, we define the AppState interface, and make sure that the object keys matches the object keys of the reducer object literal passed to NgRx, so that we can use store.select(appstate => appstate.r1)
(and is this the only useful case of AppState interface)?