Minor Changes
-
#4596
6113a590a
Thanks @davidkpiano! - IntroducegetNextSnapshot(...)
, which determines the next snapshot for the givenactorLogic
based on the givensnapshot
andevent
.If the
snapshot
isundefined
, the initial snapshot of theactorLogic
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'