Naked Panda Meditations

    jetstate

    1.3.1 • Public • Published

    jetstate

    NPM

    install size dependencies

    Version License Downloads

    state managment

    install

    npm i jetstate --save
    

    use

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

    Keywords

    none

    Install

    npm i jetstate

    DownloadsWeekly Downloads

    13

    Version

    1.3.1

    License

    ISC

    Unpacked Size

    4.1 kB

    Total Files

    4

    Last publish

    Collaborators

    • itten