This project adheres to Semantic Versioning.
- Update [email protected]
- Scoped events
- Update [email protected]
- Better support for @changed event, handler now will be called only/always when the related sub state will be changed
- Update [email protected]
- Better types handling for optional state properties
- Reimplenting in typescript
- Update [email protected]
- Simplification.
-
The state returned from events handler have to be full sub state. It will be not merged with previous but will be replacing old one.
Example :
import createStore from "storeon"; const store = createStore([]); const featureStore = createSubstore(store, 'feature'); featureStore.on('a', (state, data) => ({ a: data})); featureStore.on('b', (state, data) => ({ b: data })); featureStore.dispatch('a', 'a'); featureStore.dispatch('b', 'b'); // previously console.log(store.get()); // {feature: {a: 'a', b: 'b'}} // now console.log(store.get()); // {feature: {b: 'b'}}
To have same behaviour as before the change always merge current state with new one:
import createStore from "storeon"; const store = createStore([]); const featureStore = createSubstore(store, 'feature'); featureStore.on('a', (state, data) => ({ ...state, a: data})); featureStore.on('b', (state, data) => ({ ...state, b: data })); featureStore.dispatch('a', 'a'); featureStore.dispatch('b', 'b'); console.log(store.get()); // {feature: {a: 'a', b: 'b'}}
- Performance optimization.
- Fix for infinite loop on undefined return from handler.
- Added support to reduce primitive values.
- Initial release.