Patch Changes
-
#3040
18dc2b3e2
Thanks @davidkpiano! - TheAnyState
andAnyStateMachine
types are now available, which can be used to express any state and state machine, respectively:import type { AnyState, AnyStateMachine } from 'xstate'; // A function that takes in any state machine function visualizeMachine(machine: AnyStateMachine) { // (exercise left to reader) } function logState(state: AnyState) { // ... }
-
#3042
e53396f08
Thanks @suerta-git! - Added theAnyStateConfig
type, which represents anyStateConfig<...>
:import type { AnyStateConfig } from 'xstate'; import { State } from 'xstate'; // Retrieving the state config from localStorage const stateConfig: AnyStateConfig = JSON.parse( localStorage.getItem('app-state') ); // Use State.create() to restore state from config object with correct type const previousState = State.create(stateConfig);