github statelyai/xstate xstate@6.0.0-alpha.7

latest release: xstate@6.0.0-alpha.8
pre-release8 hours ago

Major Changes

  • 89895f9: Add createSystem({ registry }) for declaring typed actor registry keys and creating actors in that system.

    Registry keys are assigned with registryKey on invokes, spawned actors, and root actors created from the system. Registry keys are checked against the declared registry when using createSystem.

    const system = createSystem({
      registry: {
        receiver: receiverLogic
      }
    });
    
    const machine = system.setup().createMachine({
      invoke: {
        src: receiverLogic,
        registryKey: 'receiver'
      }
    });
    
    const actor = system.createActor(machine).start();
    
    system.get('receiver')?.send({ type: 'HELLO' });

Patch Changes

  • 89895f9: Static transition config objects may now include a shallow context patch.

    createMachine({
      context: { draftAnyway: false, count: 0 },
      initial: 'idle',
      states: {
        idle: {
          on: {
            DRAFT_ANYWAY: {
              target: 'drafting',
              context: { draftAnyway: true }
            }
          }
        },
        drafting: {}
      }
    });

    The patch is shallow-merged with the current context, just like context returned from a transition function. Setup-typed machines still require any keys needed by the target state's narrowed context.

Don't miss a new xstate release

NewReleases is sending notifications on new releases.