github statelyai/xstate xstate@5.0.0-beta.31

latest releases: @xstate/vue@4.0.0, @xstate/store@2.6.1, @xstate/svelte@4.0.0...
pre-release13 months ago

Major Changes

  • #4306 30e3cb216 Thanks @Andarist! - The final output of a state machine is now specified directly in the output property of the machine config:

    const machine = createMachine({
      initial: 'started',
      states: {
        started: {
          // ...
        },
        finished: {
          type: 'final'
          // moved to the top level
          //
          // output: {
          //   status: 200
          // }
        }
      },
      // This will be the final output of the machine
      // present on `snapshot.output` and in the done events received by the parent
      // when the machine reaches the top-level final state ("finished")
      output: {
        status: 200
      }
    });

Minor Changes

  • #4172 aeef5e2d0 Thanks @davidkpiano! - The onSnapshot: { ... } transition object is now supported for invoked machines, observables, promises, and transition functions:

    const machine = createMachine({
      // ...
      invoke: [
        {
          src: createMachine({ ... }),
          onSnapshot: {
            actions: (context, event) => {
              event.snapshot; // machine state
            }
          }
        },
        {
          src: fromObservable(() => ...),
          onSnapshot: {
            actions: (context, event) => {
              event.snapshot; // observable value
            }
          }
        },
        {
          src: fromTransition((state, event) => { ... }, /* ... */),
          onSnapshot: {
            actions: (context, event) => {
              event.snapshot; // transition function return value
            }
          }
        }
      ]
    });

Patch Changes

  • #4307 0c7b3aa3d Thanks @davidkpiano! - The input of a callback actor created with fromCallback(...) will now be properly restored when the actor is persisted.

Don't miss a new xstate release

NewReleases is sending notifications on new releases.