Illutions Engine API - v0.26.0
    Preparing search index...

    Class StateMachine

    Manages the lifecycle of an XState state machine within the application. The class encapsulates the creation and execution of a state machine actor, providing a controlled interface to start, monitor, and debug its runtime behavior.

    Index
    • Starts the provided XState state machine and initializes its corresponding actor.

      Parameters

      • stateMachine: AnyStateMachine

        A fully constructed XState 5 machine.

        Example

        import { type AnyStateMachine, setup } from 'xstate';
        import { App, cfg, SceneReadyEvent } from 'illutions';

        const classes = {};

        function createStateMachine(app: App): AnyStateMachine {
        const { orbitCtrls } = app;

        return setup({
        types: {} as {
        events: SceneReadyEvent;
        },
        actions: { enableOrbitCtrls: () => orbitCtrls.enable(), },
        }).createMachine({
        id: 'App',
        initial: 'Start',
        states: {
        Start: {
        on: {
        SCENE_READY: { actions: 'enableOrbitCtrls' },
        },
        }
        },
        });
        }

        // Wait until the DOM is fully loaded before creating the app.
        document.addEventListener('DOMContentLoaded', async () => {
        App.run(cfg, classes, createStateMachine);
        });

      Returns void