github statelyai/xstate xstate@4.30.1

latest releases: @xstate/vue@4.0.0, @xstate/store@2.6.1, @xstate/svelte@4.0.0...
2 years ago

Patch Changes

  • #3040 18dc2b3e2 Thanks @davidkpiano! - The AnyState and AnyStateMachine 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 the AnyStateConfig type, which represents any StateConfig<...>:

    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);

Don't miss a new xstate release

NewReleases is sending notifications on new releases.