2.0.1 • Published 3 years ago

@remvst/state-machine v2.0.1

Weekly downloads
4
License
UNLICENSED
Repository
-
Last release
3 years ago

state-machine

Usage

const StateMachine = require('@remvst/state-machine');

const myStateMachine = new StateMachine();
const initialState = myStateMachine.state('initial');
const secondState = myStateMachine.state('second');

initialState
    .onEnter(context => console.log('entering the initial state'))
    .onExit(context => console.log('leaving the initial state'))
    .onUpdate(context => context.transition());

secondState
    .onEnter(context => console.log('entering the second state'));

const context = myStateMachine.context(initialState);
context.update({'update': 'parameters'});

// Output:
// entering the initial state
// leaving the initial state
// entering the second state
2.0.1

3 years ago

2.0.0

3 years ago

1.0.1

5 years ago

1.0.0

5 years ago