Download Latest Version @xstate_store@3.9.3 source code.tar.gz (6.7 MB)
Email in envelope

Get an email when there's a new version of XState

Home / xstate@5.22.0
Name Modified Size InfoDownloads / Week
Parent folder
README.md 2025-09-18 1.8 kB
xstate@5.22.0 source code.tar.gz 2025-09-18 6.7 MB
xstate@5.22.0 source code.zip 2025-09-18 7.2 MB
Totals: 3 Items   13.9 MB 0

Minor Changes

  • #5367 76c857e Thanks @davidkpiano! - Add type-bound action helpers to setup():

    • createAction(fn) – create type-safe custom actions
    • setup().assign(...), setup().sendTo(...), setup().raise(...), setup().log(...), setup().cancel(...), setup().stopChild(...), setup().enqueueActions(...), setup().emit(...), setup().spawnChild(...) – setup-scoped helpers that are fully typed to the setup's context/events/actors/guards/delays/emitted.

    These helpers return actions that are bound to the specific setup() they were created from and can be used directly in the machine produced by that setup.

    ```ts const machineSetup = setup({ types: {} as { context: { count: number; }; events: { type: 'inc'; value: number } | { type: 'TEST' }; emitted: { type: 'PING' }; } });

    // Custom action const action = machineSetup.createAction(({ context, event }) => { console.log(context.count, event.value); });

    // Type-bound built-ins (no wrapper needed) const increment = machineSetup.assign({ count: ({ context }) => context.count + 1 }); const raiseTest = machineSetup.raise({ type: 'TEST' }); const ping = machineSetup.emit({ type: 'PING' }); const batch = machineSetup.enqueueActions(({ enqueue, check }) => { if (check(() => true)) { enqueue(increment); } });

    const machine = machineSetup.createMachine({ context: { count: 0 }, entry: [action, increment, raiseTest, ping, batch] }); ```

Source: README.md, updated 2025-09-18