1.0.1 • Published 3 years ago

@jswork/next-fsm v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

next-fsm

A finite state machine for next.

version license size download

installation

npm install -S @jswork/next-fsm

apis

apiparamsdescription
init-initial state
transitions-states list
onTransition-When transition change
transition-Change state directly

usage

import NxFsm from 'next-fsm';

const fsm = new nx.Fsm({
  init: false,
  transitions: [
    { name: 'on', from: false, to: true },
    { name: 'off', from: true, to: false }
  ],
  onTransition: function(inEvent) {
    const { value } = inEvent.target;
    times++;
    console.log('current state:', value);
  }
});

fsm.on();
fsm.off();

fsm.transition('on');
fsm.transition('off');

resources

license

Code released under the MIT license.