simple state management library for frontend
$ npm install --save simple-state-management
https://simple-state-management.netlify.app/
$ cd demo
$ npm install .
$ npm run start
-> localhost:8080
https://hostile-architecture.org/
stores.js
import SimpleStateManagement from 'simple-state-management';
import actions from './actions';
import getters from './getters';
import mutations from './mutations';
import states from './states';
export default new SimpleStateManagement({
actions,
mutations,
getters,
states
});
app.js
import store from './stores';
...
// Fire dispatch event for api fetching or something
store.dispatch('todos.fetchList');
...
// Subcribe event
this.unsbscribe = store.subscribe('todos', () => {
this.list = store.getters('todos.list');
this.render();
});
...
// Render view
render() {
console.log('render => ', this.list);
}
...
unmount() {
this.unsbscribe();
}