github statelyai/xstate xstate@5.5.0

latest releases: @xstate/solid@0.2.3, @xstate/svelte@3.0.5, @xstate/vue@3.1.4...
10 months ago

Minor Changes

  • #4596 6113a590a Thanks @davidkpiano! - Introduce getNextSnapshot(...), which determines the next snapshot for the given actorLogic based on the given snapshot and event.

    If the snapshot is undefined, the initial snapshot of the actorLogic is used.

    import { getNextSnapshot } from 'xstate';
    import { trafficLightMachine } from './trafficLightMachine.ts';
    
    const nextSnapshot = getNextSnapshot(
      trafficLightMachine, // actor logic
      undefined, // snapshot (or initial state if undefined)
      { type: 'TIMER' }
    ); // event object
    
    console.log(nextSnapshot.value);
    // => 'yellow'
    
    const nextSnapshot2 = getNextSnapshot(
      trafficLightMachine, // actor logic
      nextSnapshot, // snapshot
      { type: 'TIMER' }
    ); // event object
    
    console.log(nextSnapshot2.value);
    // =>'red'

Patch Changes

  • #4659 1ae07f5bf Thanks @Andarist! - Allow event in transitions to be narrowed down even when its .type is defined using a union.

Don't miss a new xstate release

NewReleases is sending notifications on new releases.