XState 6.0.0-alpha.37

6.0.0-alpha.37Pre-release
Added 2
  • Add an experimental, host-neutral durable execution helper at `xstate/durable` that assigns stable IDs to effects and event waits from pure transitions while leaving durable execution, timers, messaging and child actors to the host
  • Add experimental durable execution adapters for Inngest and Rivet workflows
Changed 1
  • Host runtime mappings now receive the complete built-in effect, allowing them to map timers, sends and child actors without coupling XState to either host
Fixed 1
  • Fix `invoke.onDone` transition argument inference when actor logic is passed directly as `src` in a machine with two or more differently-typed registered actors so that `event.output` is properly inferred from the invoked actor's output type
Minor Changes
  • 86f7303: Add an experimental, host-neutral durable execution helper at xstate/durable. It assigns stable IDs to effects and event waits from pure transitions while leaving durable execution, timers, messaging and child actors to the host. Hosts can read nextTransitionIndex after every transition for checkpointing.

    const durable = createDurable(machine, adapter);
    const output = await durable.run(input);
    
Patch Changes
  • 86f7303: Add experimental durable execution adapters for Inngest and Rivet workflows. Host runtime mappings now receive the complete built-in effect, allowing them to map timers, sends and child actors without coupling XState to either host.

    import { createDurable } from '@xstate/inngest';
    
    const output = await createDurable(machine, options).run(input);
    
  • 6df07b8: Fixed invoke.onDone transition argument inference when actor logic is passed directly as src in a machine with two or more differently-typed registered actors. Previously, the transition function's arguments collapsed to any (event.output was unusable without annotations); now event.output is inferred from the invoked actor's output type.

    const fetchUser = createAsyncLogic({ run: async () => ({ name: 'David' }) });
    const fetchCount = createAsyncLogic({ run: async () => 42 });
    
    setup({
      actors: { fetchUser, fetchCount }
    }).createMachine({
      initial: 'loading',
      states: {
        loading: {
          invoke: {
            src: fetchUser,
            onDone: ({ event }) => {
              event.output.name; // string
              return { target: 'done' };
            }
          }
        },
        done: {}
      }
    });
    

    Note: when actors are registered, invoking unregistered inline logic now only supports the object/target forms of onDone (not the transition function form). Register the actor to get fully-typed function-form transitions.

View original

Upgraded? How did it go?

Discussion