Package Exports
- subjective
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (subjective) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Subjective
- Opinionated state management
- Type safety by design
- Selector functions
- Update functions
- Composition
- RxJS 5.5 & RxJS 6 compatibility
Concepts
State
// define new state
const state = new Subjective(
productState,
productStateFns,
);
Selector function
// subscribe to state.filter.type
state.select(s => s.filter.type).subscribe(type => {
console.log(type);
});
Update function
// change value of state.filter.type
state.update(f => f.updateFilterType, type);
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.