Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tflx/state-machine


https://github.com/tflx/state-machine

Last synced: about 2 months ago
JSON representation

Awesome Lists containing this project

README

        

# State Machine

Based on https://github.com/andybelldesign/beedle which is based on this article https://css-tricks.com/build-a-state-management-system-with-vanilla-javascript/

## Publish state change
```javascript
import store from './store/index.js';

store.dispatch('addItem', 'A new item');
```

## Subscribe to state change
```javascript
import store from './store/index.js';

constructor() {
store.subscribe('stateChange', () => this.render());
}

render = () => {
console.log(store.state.items);

/**
Compare to local state and update/re-render if necessary
*/
}
```