Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/behnammodi/jetstate

state managment
https://github.com/behnammodi/jetstate

Last synced: about 1 month ago
JSON representation

state managment

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)


Version


License


Downloads

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();
```