import { getNextSnapshot } from "https://deno.land/x/xstate@xstate@5.8.1/src/getNextSnapshot.ts";
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.
Examples
Example 1
Example 1
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'
Type Parameters
T extends AnyActorLogic