Subjective
- Opinionated state management
- Type safety by design. Type inference works for both Update and Selector functions.
- Logging. Inspect where Update function was called.
- Pause observable stream, if needed.
- Always receive the whole state, if needed.
Concepts
State
;
Default Logger
;
Custom Logger
;
Selector function
Subscribe to state.filter.type and notify with its value
state.selects.filter.type.subscribe;
Subscribe to state.filter.type and notify with a whole state
state.selects.filter.type, true.subscribe;
Update function
Update value of state.filter.type
state.updatef.updateFilterType, type;
Update value of state.filter.type and do not notify subscribers
state.updatef.updateFilterType, type, false;
Update value of state.filter.type and return updated state
;
Examples
NOTES
Immutable pattern
Always use immutable pattern otherwise it will not work. We can't rely on mutations since object reference is always the same.
Type-safety
Types are always inferred either from state class or payload parameter of the update function.
FUTURE
I've been thinking of this new syntax...check it out.