Update dependency xstate to v5
Note: This PR body was truncated due to platform limits.
This PR contains the following updates:
| Package | Change | Age | Confidence |
|---|---|---|---|
| xstate (source) | ^4.38.3 → ^5.25.0 |
Release Notes
statelyai/xstate (xstate)
v5.25.0
Minor Changes
-
#5422
329297bThanks @davidkpiano! - Add partial descriptor support toassertEvent(…)// Matches any event with a type that starts with `FEEDBACK.` assertEvent(event, 'FEEDBACK.*');
Patch Changes
-
#5420
2eb8274Thanks @assertnotnull! - Fix a bug in Cordova when iterating an empty Map
v5.24.0
Minor Changes
-
#5371
b8ec3b1Thanks @davidkpiano! - Addsetup.extend()method to incrementally extend machine setup configurations with additional actions, guards, and delays. This enables composable and reusable machine setups where extended actions, guards, and delays can reference base actions, guards, and delays and support chaining multiple extensions:import { setup, not, and } from 'xstate'; const baseSetup = setup({ guards: { isAuthenticated: () => true, hasPermission: () => false } }); const extendedSetup = baseSetup.extend({ guards: { // Type-safe guard references isUnauthenticated: not('isAuthenticated'), canAccess: and(['isAuthenticated', 'hasPermission']) } }); // Both base and extended guards are available extendedSetup.createMachine({ on: { LOGIN: { guard: 'isAuthenticated', target: 'authenticated' }, LOGOUT: { guard: 'isUnauthenticated', target: 'unauthenticated' } } });
v5.23.0
Minor Changes
-
#5387
53dd7f1Thanks @farskid! - Addssystem.getAllthat returns a record of running actors within the system by their system idconst childMachine = createMachine({}); const machine = createMachine({ // ... invoke: [ { src: childMachine, systemId: 'test' } ] }); const system = createActor(machine); system.getAll(); // { test: ActorRefFrom<typeof childMachine> }
v5.22.1
Patch Changes
-
#5379
98f9dddThanks @davidkpiano! - Makeactor.systemIdpublic:const actor = createActor(machine, { systemId: 'test' }); actor.systemId; // 'test' -
#5380
e7e5e44Thanks @Nirajkashyap! - fix: remove 'eventType' from required fields in initialTransitionObject
v5.22.0
Minor Changes
-
#5367
76c857eThanks @davidkpiano! - Add type-bound action helpers tosetup():-
createAction(fn)– create type-safe custom actions -
setup().assign(...),setup().sendTo(...),setup().raise(...),setup().log(...),setup().cancel(...),setup().stopChild(...),setup().enqueueActions(...),setup().emit(...),setup().spawnChild(...)– setup-scoped helpers that are fully typed to the setup's context/events/actors/guards/delays/emitted.
These helpers return actions that are bound to the specific
setup()they were created from and can be used directly in the machine produced by that setup.const machineSetup = setup({ types: {} as { context: { count: number; }; events: { type: 'inc'; value: number } | { type: 'TEST' }; emitted: { type: 'PING' }; } }); // Custom action const action = machineSetup.createAction(({ context, event }) => { console.log(context.count, event.value); }); // Type-bound built-ins (no wrapper needed) const increment = machineSetup.assign({ count: ({ context }) => context.count + 1 }); const raiseTest = machineSetup.raise({ type: 'TEST' }); const ping = machineSetup.emit({ type: 'PING' }); const batch = machineSetup.enqueueActions(({ enqueue, check }) => { if (check(() => true)) { enqueue(increment); } }); const machine = machineSetup.createMachine({ context: { count: 0 }, entry: [action, increment, raiseTest, ping, batch] }); -
v5.21.0
Minor Changes
-
#5364
15e15b5Thanks @davidkpiano! - Added.createStateConfig(…)to the setup API. This makes it possible to create state configs that are strongly typed and modular.const lightMachineSetup = setup({ // ... }); const green = lightMachineSetup.createStateConfig({ //... }); const yellow = lightMachineSetup.createStateConfig({ //... }); const red = lightMachineSetup.createStateConfig({ //... }); const machine = lightMachineSetup.createMachine({ initial: 'green', states: { green, yellow, red } });
v5.20.2
Patch Changes
-
#5351
71387ffThanks @davidkpiano! - Fix: Emit callback errors no longer crash the actoractor.on('event', () => { // Will no longer crash the actor throw new Error('oops'); });
v5.20.1
Patch Changes
-
#5315
9a0ae82Thanks @sfc-gh-dperezalvarez! - ExportedInspectedActionEventtype
v5.20.0
Minor Changes
-
#5287
e07a7cd8462473188a0fb646a965e61be1ce6ae3Thanks @davidkpiano! - The graph and model-based testing utilities from @xstate/graph (and @xstate/test previously) were moved to the corexstatepackage.import { createMachine } from 'xstate'; import { getShortestPaths } from 'xstate/graph'; const machine = createMachine({ // ... }); const paths = getShortestPaths(machine, { fromState: 'a', toState: 'b' });
v5.19.4
Patch Changes
-
#5289
479c74b83fa77c57c48f54cf0e9dcfab5fe6cae5Thanks @ebadyz! - Removed outdatedcontextparameter reference fromprovidemethod documentation.
v5.19.3
Patch Changes
-
#5269
b453b2d72ba12d0fe46a995f9ccced8000fd0cc9Thanks @chladog! - Add proper history value persistence and restoration
v5.19.2
Patch Changes
-
#5170
d99df1d8f4fe49145c9974465b65028bf19b365fThanks @Andarist! - Improved compatibility of inferred types in projects withexactOptionalPropertyTypesenabled
v5.19.1
Patch Changes
-
#5139
bf6119a7310a878afbf4f5b01f5e24288f9a0f16Thanks @SandroMaglione! - Makespawninput required when defined inside referenced actor:const childMachine = createMachine({ types: { input: {} as { value: number } } }); const machine = createMachine({ types: {} as { context: { ref: ActorRefFrom<typeof childMachine> } }, context: ({ spawn }) => ({ ref: spawn( childMachine, // Input is now required! { input: { value: 42 } } ) }) });
v5.19.0
Minor Changes
-
#4954
8c4b70652acaef2702f32435362e4755679a516dThanks @davidkpiano! - Added a newtransitionfunction that takes an actor logic, a snapshot, and an event, and returns a tuple containing the next snapshot and the actions to execute. This function is a pure function and does not execute the actions itself. It can be used like this:import { transition } from 'xstate'; const [nextState, actions] = transition(actorLogic, currentState, event); // Execute actions as neededAdded a new
initialTransitionfunction that takes an actor logic and an optional input, and returns a tuple containing the initial snapshot and the actions to execute from the initial transition. This function is also a pure function and does not execute the actions itself. It can be used like this:import { initialTransition } from 'xstate'; const [initialState, actions] = initialTransition(actorLogic, input); // Execute actions as neededThese new functions provide a way to separate the calculation of the next snapshot and actions from the execution of those actions, allowing for more control and flexibility in the transition process.
v5.18.2
Patch Changes
-
#5079
25963966c394fc904dc9b701a420b6e204ebe7f7Thanks @davidkpiano! - The inspection event interfaces now expectActorRefLikeinstead ofAnyActorRef
v5.18.1
Patch Changes
-
#5055
ad38c35c37Thanks @SandroMaglione! - ExportedRequiredActorOptionsKeystype meant to be used by integration packages like@xstate/react
v5.18.0
Minor Changes
-
#5042
54c9d9e6a4Thanks @boneskull! -waitFor()now accepts a{signal: AbortSignal}inWaitForOptions -
#5006
1ab974547fThanks @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
853f6daa0bThanks @davidkpiano! - TheCallbackLogicFunctiontype (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'; // ...
v5.17.4
Patch Changes
-
#5039
d6df8fb470Thanks @Andarist! - Fixed an inference issue that preventedemitused directly insetup(or barecreateMachine) to benefit fromtypes.emittedtypes.
v5.17.3
Patch Changes
-
#5034
7bed484c38Thanks @davidkpiano! - FixEventFromandContextFromtypes
v5.17.2
Patch Changes
-
#5029
88bd87ab41Thanks @davidkpiano! - RevertActorRefFromchange -
#5011
a275d274deThanks @davidkpiano! - There is a new type helper:ActorRefFromLogic<TLogic>. This type is a stricter form ofActorRefFrom<TLogic>that only accepts actor logic types. See #4997 for more details.
v5.17.1
Patch Changes
-
#5009
51d4c4fc5Thanks @davidkpiano! - The internal types forStateMachine<...>have been improved so that all type params are required, to prevent errors when using the types. This fixes weird issues like #5008.
v5.17.0
Minor Changes
-
#4979
a0e9ebcefThanks @davidkpiano! - State IDs are now strongly typed as keys ofsnapshot.getMeta()for state machine actor snapshots.const machine = setup({ // ... }).createMachine({ id: 'root', initial: 'parentState', states: { parentState: { meta: {}, initial: 'childState', states: { childState: { meta: {} }, stateWithId: { id: 'state with id', meta: {} } } } } }); const actor = createActor(machine); const metaValues = actor.getSnapshot().getMeta(); // Auto-completed keys: metaValues.root; metaValues['root.parentState']; metaValues['root.parentState.childState']; metaValues['state with id']; // @​ts-expect-error metaValues['root.parentState.stateWithId']; // @​ts-expect-error metaValues['unknown state'];
Patch Changes
-
#5002
9877d548bThanks @davidkpiano! - Fix an issue whereclearTimeout(undefined)was sometimes being called, which can cause errors for some clock implementations. See #5001 for details.
v5.16.0
Minor Changes
-
#4996
5be796cd2Thanks @ronvoluted! - The actor snapshotstatustype ('active' | 'done' | 'error' | 'stopped') is now exposed asSnapshotStatus -
#4981
c4ae156b2Thanks @davidkpiano! - AddedsendParentto theenqueueActionsfeature. This allows users to enqueue actions that send events to the parent actor within theenqueueActionsblock.import { createMachine, enqueueActions } from 'xstate'; const childMachine = createMachine({ entry: enqueueActions(({ enqueue }) => { enqueue.sendParent({ type: 'CHILD_READY' }); }) });
v5.15.0
Minor Changes
-
#4976
452bce71eThanks @with-heart! - Added exports for actor logic-specificActorReftypes:CallbackActorRef,ObservableActorRef,PromiseActorRef, andTransitionActorRef.Each type represents
ActorRefnarrowed to the corresponding type of logic (the type ofselfwithin the actor's logic):-
CallbackActorRef: actor created byfromCallbackimport { fromCallback, createActor } from 'xstate'; /** The events the actor receives. */ type Event = { type: 'someEvent' }; /** The actor's input. */ type Input = { name: string }; /** Actor logic that logs whenever it receives an event of type `someEvent`. */ const logic = fromCallback<Event, Input>(({ self, input, receive }) => { self; // ^? CallbackActorRef<Event, Input> receive((event) => { if (event.type === 'someEvent') { console.log(`${input.name}: received "someEvent" event`); // logs 'myActor: received "someEvent" event' } }); }); const actor = createActor(logic, { input: { name: 'myActor' } }); // ^? CallbackActorRef<Event, Input> -
ObservableActorRef: actor created byfromObservableandfromEventObservableimport { fromObservable, createActor } from 'xstate'; import { interval } from 'rxjs'; /** The type of the value observed by the actor's logic. */ type Context = number; /** The actor's input. */ type Input = { period?: number }; /** * Actor logic that observes a number incremented every `input.period` * milliseconds (default: 1_000). */ const logic = fromObservable<Context, Input>(({ input, self }) => { self; // ^? ObservableActorRef<Event, Input> return interval(input.period ?? 1_000); }); const actor = createActor(logic, { input: { period: 2_000 } }); // ^? ObservableActorRef<Event, Input> -
PromiseActorRef: actor created byfromPromiseimport { fromPromise, createActor } from 'xstate'; /** The actor's resolved output. */ type Output = string; /** The actor's input. */ type Input = { message: string }; /** Actor logic that fetches the url of an image of a cat saying `input.message`. */ const logic = fromPromise<Output, Input>(async ({ input, self }) => { self; // ^? PromiseActorRef<Output, Input> const data = await fetch(`https://cataas.com/cat/says/${input.message}`); const url = await data.json(); return url; }); const actor = createActor(logic, { input: { message: 'hello world' } }); // ^? PromiseActorRef<Output, Input> -
TransitionActorRef: actor created byfromTransitionimport { fromTransition, createActor, type AnyActorSystem } from 'xstate'; /** The actor's stored context. */ type Context = { /** The current count. */ count: number; /** The amount to increase `count` by. */ step: number; }; /** The events the actor receives. */ type Event = { type: 'increment' }; /** The actor's input. */ type Input = { step?: number }; /** * Actor logic that increments `count` by `step` when it receives an event of * type `increment`. */ const logic = fromTransition<Context, Event, AnyActorSystem, Input>( (state, event, actorScope) => { actorScope.self; // ^? TransitionActorRef<Context, Event> if (event.type === 'increment') { return { ...state, count: state.count + state.step }; } return state; }, ({ input, self }) => { self; // ^? TransitionActorRef<Context, Event> return { count: 0, step: input.step ?? 1 }; } ); const actor = createActor(logic, { input: { step: 10 } }); // ^? TransitionActorRef<Context, Event>
-
-
#4949
8aa4c2b90Thanks @davidkpiano! - The TypeGen-related types have been removed from XState, simplifying the internal types without affecting normal XState usage.
v5.14.0
Minor Changes
-
#4936
c58b36dc3Thanks @davidkpiano! - Inspecting an actor system viaactor.system.inspect(ev => …)now accepts a function or observer, and returns a subscription:const actor = createActor(someMachine); const sub = actor.system.inspect((inspectionEvent) => { console.log(inspectionEvent); }); // Inspection events will be logged actor.start(); actor.send({ type: 'anEvent' }); // ... sub.unsubscribe(); // Will no longer log inspection events actor.send({ type: 'someEvent' }); -
#4942
9caaa1f70Thanks @boneskull! -DoneActorEventandErrorActorEventnow contain propertyactorId, which refers to the ID of the actor the event refers to. -
#4935
2ac08b700Thanks @davidkpiano! - All actor logic creators now support emitting events:Promise actors
const logic = fromPromise(async ({ emit }) => { // ... emit({ type: 'emitted', msg: 'hello' }); // ... });Transition actors
const logic = fromTransition((state, event, { emit }) => { // ... emit({ type: 'emitted', msg: 'hello' }); // ... return state; }, {});Observable actors
const logic = fromObservable(({ emit }) => { // ... emit({ type: 'emitted', msg: 'hello' }); // ... });Callback actors
const logic = fromCallback(({ emit }) => { // ... emit({ type: 'emitted', msg: 'hello' }); // ... });
Patch Changes
-
#4929
417f35a11Thanks @boneskull! - Expose typeUnknownActorReffor use when callinggetSnapshot()on an unknownActorRef.
v5.13.2
Patch Changes
-
#4932
71a7f8692Thanks @davidkpiano! - Actors with emitted events should no longer cause type issues: #4931
v5.13.1
Patch Changes
-
#4905
dbeafeb25Thanks @davidkpiano! - You can now use a wildcard to listen for any emitted event from an actor:actor.on('*', (emitted) => { console.log(emitted); // Any emitted event });
v5.13.0
Minor Changes
-
#4832
148d8fcefThanks @cevr! -fromPromisenow passes a signal into its creator function.const logic = fromPromise(({ signal }) => fetch('https://api.example.com', { signal }) );This will be called whenever the state transitions before the promise is resolved. This is useful for cancelling the promise if the state changes.
Patch Changes
-
#4876
3f6a73b56Thanks @davidkpiano! - XState will now warn when calling built-in actions likeassign,sendTo,raise,emit, etc. directly inside of a custom action. See https://stately.ai/docs/actions#built-in-actions for more details.const machine = createMachine({ entry: () => { // Will warn: // "Custom actions should not call \`assign()\` directly, as it is not imperative. See https://stately.ai/docs/actions#built-in-actions for more details." assign({ // ... }); } });
v5.12.0
Minor Changes
-
#4863
0696adc21Thanks @davidkpiano! - Meta objects for state nodes and transitions can now be specified insetup({ types: … }):const machine = setup({ types: { meta: {} as { layout: string; } } }).createMachine({ initial: 'home', states: { home: { meta: { layout: 'full' } } } }); const actor = createActor(machine).start(); actor.getSnapshot().getMeta().home; // => { layout: 'full' } // if in "home" state
v5.11.0
Minor Changes
-
#4806
f4e0ec48cThanks @davidkpiano! - Inline actor logic is now permitted when named actors are present. Defining inline actors will no longer cause a TypeScript error:const machine = setup({ actors: { existingActor: fromPromise(async () => { // ... }) } }).createMachine({ invoke: { src: fromPromise(async () => { // Inline actor }) // ... } });
v5.10.0
Minor Changes
-
#4822
f7f1fbbf3Thanks @davidkpiano! - Theclockandloggerspecified in theoptionsobject ofcreateActor(logic, options)will now propagate to all actors created within the same actor system.import { setup, log, createActor } from 'xstate'; const childMachine = setup({ // ... }).createMachine({ // ... // Uses custom logger from root actor entry: log('something') }); const parentMachine = setup({ // ... }).createMachine({ // ... invoke: { src: childMachine } }); const actor = createActor(parentMachine, { logger: (...args) => { // custom logger for args } }); actor.start();
v5.9.1
Patch Changes
-
#4780
567267ed2Thanks @Andarist! - Add missingemitexport
v5.9.0
Minor Changes
-
#4746
b570ba20dThanks @davidkpiano! - The newemit(…)action creator emits events that can be received by listeners. Actors are now event emitters.import { emit } from 'xstate'; const machine = createMachine({ // ... on: { something: { actions: emit({ type: 'emitted', some: 'data' }) } } // ... }); const actor = createActor(machine).start(); actor.on('emitted', (event) => { console.log(event); }); actor.send({ type: 'something' }); // logs: // { // type: 'emitted', // some: 'data' // } -
#4777
4abeed9dfThanks @Andarist! - Added support forparamstoenqueueActions
v5.8.2
Patch Changes
-
#4772
9a0120901Thanks @Andarist! - Fixed a type issue that preventsendParentto be accepted bysetupwhendelaysstayed not configured.
v5.8.1
Patch Changes
-
#4768
4a29f8aabThanks @Andarist! - Correctly use falsy outputs (instead of accidentally converting them toundefined).
v5.8.0
Minor Changes
-
#4750
a9e3c086fThanks @Andarist! - Revampedsetupand actions types to disallow usage of non-configured implementations
v5.7.1
Patch Changes
-
#4739
15b7dd1f0Thanks @devanfarrell! - Removedthisfrom machine snapshot methods to fix issues with accessing those methods from union of actors and their snapshots.
v5.7.0
Minor Changes
-
#4290
7a8796f80Thanks @davidkpiano! - An error will now be thrown if an incompatible state value is passed tomachine.resolveState({ value }). -
#4693
11b6a1ae1Thanks @davidkpiano! - You can now inspect microsteps (@xstate.microstep) and actions (@xstate.action):const machine = createMachine({ initial: 'a', states: { a: { on: { event: 'b' } }, b: { entry: 'someAction', always: 'c' }, c: {} } }); const actor = createActor(machine, { inspect: (inspEvent) => { if (inspEvent.type === '@​xstate.microstep') { console.log(inspEvent.snapshot); // logs: // { value: 'a', … } // { value: 'b', … } // { value: 'c', … } console.log(inspEvent.event); // logs: // { type: 'event', … } } else if (inspEvent.type === '@​xstate.action') { console.log(inspEvent.action); // logs: // { type: 'someAction', … } } } }); actor.start(); actor.send({ type: 'event' });
v5.6.2
Patch Changes
-
#4731
960cdcbcbThanks @davidkpiano! - You can now importgetInitialSnapshot(…)fromxstatedirectly, which is useful for getting a mock of the initial snapshot when interacting with machines (or other actor logic) withoutcreateActor(…):import { getInitialSnapshot } from 'xstate'; import { someMachine } from './someMachine'; // Returns the initial snapshot (state) of the machine const initialSnapshot = getInitialSnapshot( someMachine, { name: 'Mateusz' } // optional input );
v5.6.1
Patch Changes
-
#4728
659efd5c1Thanks @Andarist! - Fixed compatibility issue of the internal type definitions with TypeScript 5.0 -
#4712
2f1d36a9dThanks @davidkpiano! - Ensure thatInteropObservableandInteropSubscribableare present in the type definition file. -
#4694
0b6dff210Thanks @davidkpiano! - AddUnknownMachineConfigtype
v5.6.0
Minor Changes
-
#4704
78699aef6Thanks @Andarist! -createActorwill now error if the requiredinputis not given to it. -
#4688
14902e17aThanks @Andarist! - Theschemasproperty insetup(...)is now passed through to the resulting machine. This property is meant to be used with future developer tooling, and is typed asunknownfor now.
Patch Changes
-
#4706
51b844230Thanks @Andarist! - Fixed compatibility with the upcoming TypeScript 5.4
v5.5.2
Patch Changes
-
#4685
e43eab144Thanks @davidkpiano! - State IDs that have periods in them are now supported if those periods are escaped.The motivation is that external tools, such as Stately Studio, may allow users to enter any text into the state ID field. This change allows those tools to escape periods in state IDs, so that they don't conflict with the internal path-based state IDs.
E.g. if a state ID of
"Loading..."is entered into the state ID field, instead of crashing either the external tool and/or the XState state machine, it should be converted by the tool to"Loading\\.\\.\\.", and those periods will be ignored by XState.
v5.5.1
Patch Changes
-
#4667
64ee3959cThanks @Andarist! - Fixed compatibility with older versions of integration packages.
v5.5.0
Minor Changes
-
#4596
6113a590aThanks @davidkpiano! - IntroducegetNextSnapshot(...), which determines the next snapshot for the givenactorLogicbased on the givensnapshotandevent.If the
snapshotisundefined, the initial snapshot of theactorLogicis used.import { getNextSnapshot } from 'xstate'; import { trafficLightMachine } from './trafficLightMachine.ts'; const nextSnapshot = getNextSnapshot( trafficLightMachine, // actor logic undefined, // snapshot (or initial state if undefined) { type: 'TIMER' } ); // event object console.log(nextSnapshot.value); // => 'yellow' const nextSnapshot2 = getNextSnapshot( trafficLightMachine, // actor logic nextSnapshot, // snapshot { type: 'TIMER' } ); // event object console.log(nextSnapshot2.value); // =>'red'
Patch Changes
-
#4659
1ae07f5bfThanks @Andarist! - Alloweventin transitions to be narrowed down even when its.typeis defined using a union.
v5.4.1
Patch Changes
-
#4600
1f2ccb97cThanks @davidkpiano! - Typegen-based types for detecting missing implementations have been removed internally.
v5.4.0
Minor Changes
-
#4616
e8c0b15b2Thanks @Andarist! -contextfactories receiveselfnow so you can immediately pass that as part of the input to spawned actors.setup({ /* ... */ }).createMachine({ context: ({ spawn, self }) => { return { childRef: spawn('child', { input: { parent: self } }) }; } });
v5.3.1
Patch Changes
-
#4597
ae0b05f11Thanks @davidkpiano! - Update the argument object ofenqueueActions(...)to include theselfandsystemproperties:// ... entry: enqueueActions(({ self, system }) => { // ... });
v5.3.0
Minor Changes
-
#4547
8e8d2ba38Thanks @davidkpiano! - AddassertEvent(...)to help provide strong typings for events that can't be easily inferred, such as events inentryandexitactions, or ininvoke.input.The
assertEvent(event, 'someType')function will throw if the event is not the expected type. This ensures that theeventis guaranteed to have that type, and assumes that the event object has the expected payload (naturally enforced by TypeScript).// ... entry: ({ event }) => { assertEvent(event, 'greet'); // event is { type: 'greet'; message: string } assertEvent(event, ['greet', 'notify']); // event is { type: 'greet'; message: string } // or { type: 'notify'; message: string; level: 'info' | 'error' } }, exit: ({ event }) => { assertEvent(event, 'doNothing'); // event is { type: 'doNothing' } }
Patch Changes
-
#4586
97f1cbd5fThanks @Andarist! - Fixed an issue with ancestors of the default history target that lie outside of the transition domain being incorrectly entered.
v5.2.1
Patch Changes
-
#4576
677fb35b7Thanks @davidkpiano! - Update README.md
v5.2.0
Minor Changes
-
#4198
ca58904adThanks @davidkpiano! - IntroducetoPromise(actor), which creates a promise from anactorthat resolves with the actor snapshot'soutputwhen done, or rejects with the actor snapshot'serrorwhen it fails.import { createMachine, createActor, toPromise } from 'xstate'; const machine = createMachine({ // ... states: { // ... done: { type: 'final', output: 42 } } }); const actor = createActor(machine); actor.start(); const output = await toPromise(actor); console.log(output); // => 42
Patch Changes
-
#4568
a5c55fae2Thanks @Andarist! - Fixed an issue withspawnwithinassignnot returning a narrowed downActorReftype on TypeScrip 5.0 -
#4570
c11127336Thanks @Andarist! - Fixed an issue that caused acompletelistener to be called instead of theerrorone when the actor was subscribed after being stopped.
v5.1.0
Minor Changes
-
#4497
d7f220225Thanks @davidkpiano! - Internal: abstract the scheduler for delayed events so that it is handled centrally by thesystem.
Patch Changes
-
#4513
80818017bThanks @davidkpiano! - Fix higher-level logic for state machine logic
v5.0.2
Patch Changes
-
#4552 [
80b9afbae](https://redirect.github.com/statelyai/xstate/commit/80b9afbaeb943cc1378c0c67631b20
Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
- [ ] If you want to rebase/retry this PR, check this box
This PR was generated by Mend Renovate. View the repository job log.
We need a tough migration, as referred to here: https://stately.ai/docs/migration