Type Alias SharedMachine<D>

SharedMachine<D>: {
    dispatch: ((action: Action<D>) => void);
    getState: (() => State<D>);
    instance: Machine<D>;
    send: Send<D>;
    setContext: SetContext<D>;
    subscribe: ((callback: ((state: State<D>) => void)) => (() => void));
}

The shared state machine.

Type Parameters

Type declaration

  • Readonlydispatch: ((action: Action<D>) => void)

    The dispatch function to send an event to the shared state machine.

      • (action): void
      • Dispatch an action to the shared state machine.

        Parameters

        • action: Action<D>

          The action to send to the shared state machine.

        Returns void

  • ReadonlygetState: (() => State<D>)

    The current state of the shared state machine.

      • (): State<D>
      • Returns State<D>

        The current state of the shared state machine.

  • Readonlyinstance: Machine<D>

    Instance of the state machine.

  • Readonlysend: Send<D>

    The send function to send an event to the shared state machine.

  • ReadonlysetContext: SetContext<D>

    The function to set the context of the shared state machine.

  • Readonlysubscribe: ((callback: ((state: State<D>) => void)) => (() => void))

    Subscribes to state changes in the shared state machine.

      • (callback): (() => void)
      • Parameters

        • callback: ((state: State<D>) => void)

          A function that is called whenever the state machine changes state.

            • (state): void
            • Parameters

              Returns void

        Returns (() => void)

        A function to unsubscribe from state changes.

          • (): void
          • Returns void