gameplate - v2.2.0
    Preparing search index...

    Interface Machine<S, E>

    interface Machine<S extends string, E extends string> {
        current: () => S;
        send: (event: E) => S;
        matches: (state: S) => boolean;
        subscribe: (
            listener: (current: S, previous: S, event: E) => void,
        ) => Unsubscribe;
    }

    Type Parameters

    • S extends string
    • E extends string
    Index

    Properties

    current: () => S

    The current state.

    send: (event: E) => S

    Send an event. Returns the (new or unchanged) current state. If no transition is defined for (currentState, event), the event is silently ignored — same shape as XState's interpret.

    matches: (state: S) => boolean

    true if the FSM is in state. Type-narrows: fsm.matches('foo').

    subscribe: (
        listener: (current: S, previous: S, event: E) => void,
    ) => Unsubscribe

    Subscribe to transitions (not re-sends of the same state).