Minor Changes
-
#5042
54c9d9e6a4
Thanks @boneskull! -waitFor()
now accepts a{signal: AbortSignal}
inWaitForOptions
-
#5006
1ab974547f
Thanks @davidkpiano! - The state value typings for setup state machine actors (setup({}).createMachine({ ... })
) have been improved to represent the actual expected state values.const machine = setup({}).createMachine({ initial: 'green', states: { green: {}, yellow: {}, red: { initial: 'walk', states: { walk: {}, wait: {}, stop: {} } }, emergency: { type: 'parallel', states: { main: { initial: 'blinking', states: { blinking: {} } }, cross: { initial: 'blinking', states: { blinking: {} } } } } } }); const actor = createActor(machine).start(); const stateValue = actor.getSnapshot().value; if (stateValue === 'green') { // ... } else if (stateValue === 'yellow') { // ... } else if ('red' in stateValue) { stateValue; // { // red: "walk" | "wait" | "stop"; // } } else { stateValue; // { // emergency: { // main: "blinking"; // cross: "blinking"; // }; // } }
Patch Changes
-
#5054
853f6daa0b
Thanks @davidkpiano! - TheCallbackLogicFunction
type (previouslyInvokeCallback
) is now exported. This is the callback function that you pass intofromCallback(callbackLogicFn)
to create an actor from a callback function.import { type CallbackLogicFunction } from 'xstate'; // ...