1.0.6 • Published 3 years ago

simple-state-management v1.0.6

Weekly downloads
23
License
MIT
Repository
github
Last release
3 years ago

Simple State Management

License: MIT npm version

simple state management library for frontend

Installation

$ npm install --save simple-state-management

Demo

https://simple-state-management.netlify.app/

$ cd demo
$ npm install .
$ npm run start
-> localhost:8080

Real Application Demo

https://hostile-architecture.org/

Usage

Initialize library

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
});

Subscribe in your components

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();
}
1.0.6

3 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.0.11

4 years ago

0.0.10

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago