ixfx
    Preparing search index...

    Class StateMachineWithEvents<V>

    A state machine that fires events when state changes.

    const transitions = StateMachine.fromList(`a`, `b`, `c`);
    const m = new StateMachineWithEvents(transitions);
    m.addEventListener(`change`, event => {
    console.log(`${event.priorState} -> ${event.newState}`);
    });
    m.addEventListener(`stop`, event => {
    console.log(`State machine has reached final state`);
    });

    Type Parameters

    Hierarchy (View Summary)

    Index

    Accessors

    Constructors

    Methods

    • Moves to the next state if possible. If multiple states are possible, it will use the first. If machine is finalised, no error is thrown and null is returned.

      Returns null | string

      Returns new state, or null if machine is finalised