Repository navigation
xstate@4.23.2
Patch Changes
-
6c3f15c9#2551 Thanks @mattpocock! - Widened the *From utility types to allow extracting from factory functions.This allows for:
const makeMachine = () => createMachine({}); type Interpreter = InterpreterFrom<typeof makeMachine>; type Actor = ActorRefFrom<typeof makeMachine>; type Context = ContextFrom<typeof makeMachine>; type Event = EventsFrom<typeof makeMachine>;
This also works for models, behaviours, and other actor types.
The previous method for doing this was a good bit more verbose:
const makeMachine = () => createMachine({}); type Interpreter = InterpreterFrom<ReturnType<typeof machine>>;
-
413a4578#2491 Thanks @davidkpiano! - The custom.toString()method on action objects is now removed which improves performance in larger applications (see #2488 for more context). -
5e1223cd#2422 Thanks @davidkpiano! - Thecontextproperty has been removed fromStateNodeConfig, as it has never been allowed, nor has it ever done anything. The previous typing was unsafe and allowedcontextto be specified on nested state nodes:createMachine({ context: { /* ... */ }, // ✅ This is allowed initial: 'inner', states: { inner: { context: { /* ... */ } // ❌ This will no longer compile } } });
-
5b70c2ff#2508 Thanks @davidkpiano! - A race condition occurred when a child service is immediately stopped and the parent service tried to remove it from its undefined state (during its own initialization). This has been fixed, and the race condition no longer occurs. See this issue for details. -
5a9500d1#2522 Thanks @farskid, @Andarist! - Adjusted TS type definitions of thewithContextandwithConfigmethods so that they accept "lazy context" now.Example:
const copy = machine.withContext(() => ({ ref: spawn(() => {}) }));
-
84f9fcae#2540 Thanks @Andarist! - Fixed an issue withstate.hasTag('someTag')crashing when thestatewas rehydrated. -
c17dd376#2496 Thanks @VanTanev! - Add utility typeEmittedFrom<T>that extractsEmittedtype from any type which can emit data