Selectors are used to select a specific piece of state.
We can select state with
select method returns an Observable which emits when the selected state changes.
select takes a callback function which gives access to the current global state:
MiniRx comes with memoized selectors out of the box. With the selectors we can easily select and combine state. The MiniRx selectors are memoized to prevent unnecessary calculations.
createFeatureSelector selects a feature state from the global state object.
We have to use the same key that we used for registering the feature reducer (e.g. we used the 'todo' key for the todoReducer).
createSelector we can require many other selectors to create a new selector.
The last argument passed to
createSelector is the projection function.
In the projection function we can access the return values of the required selectors.
Let's use the memoized selectors to create our state Observables: