Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/behnammodi/jetstate
state managment
https://github.com/behnammodi/jetstate
Last synced: about 1 month ago
JSON representation
state managment
- Host: GitHub
- URL: https://github.com/behnammodi/jetstate
- Owner: behnammodi
- License: mit
- Created: 2018-12-14T09:42:35.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2021-02-22T11:08:39.000Z (over 3 years ago)
- Last Synced: 2024-05-21T15:15:48.389Z (6 months ago)
- Language: JavaScript
- Size: 7.81 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# jetstate
[![NPM](https://nodei.co/npm/jetstate.png)](https://nodei.co/npm/jetstate/)
[![install size](https://packagephobia.now.sh/badge?p=jetstate)](https://packagephobia.now.sh/result?p=jetstate) [![dependencies](https://david-dm.org/uxitten/jetstate.svg)](https://david-dm.org/uxitten/jetstate.svg)
state managment
## install
```npm
npm i jetstate --save
```## use
```javascript
import { init, state } from 'jetstate';/**
* initial new state
*/
init({
name: 'time',
defaultValue: new Date().getTime(),
willUpdate: (previousValue, nextValue) => {
console.log('willUpdate', previousValue, nextValue);
},
shouldUpdate: (previousValue, nextValue) => {
if (typeof nextValue 'number') return true;
else return false
},
didUpdate: value => {
console.log('didUpdate', value);
}
});var time = state.time;
//with this code, willUpdate is run and then didUpdate is run
state.time = new Date().getTime();
```