https://github.com/tflx/state-machine
https://github.com/tflx/state-machine
Last synced: 14 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/tflx/state-machine
- Owner: tflx
- Created: 2019-04-23T11:10:12.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-04-25T08:30:19.000Z (about 6 years ago)
- Last Synced: 2025-07-01T09:07:18.626Z (14 days ago)
- Language: JavaScript
- Size: 71.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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
*/
}
```