4.12.0
Minor Changes
b72e29dd
#1354 Thanks @davidkpiano! - TheAction
type was simplified, and as a result, you should see better TypeScript performance.
-
4dbabfe7
#1320 Thanks @davidkpiano! - Theinvoke.src
property now accepts an object that describes the invoke source with itstype
and other related metadata. This can be read from theservices
option in themeta.src
argument:const machine = createMachine( { initial: 'searching', states: { searching: { invoke: { src: { type: 'search', endpoint: 'example.com' } // ... } // ... } } }, { services: { search: (context, event, { src }) => { console.log(src); // => { endpoint: 'example.com' } } } } );
Specifying a string for
invoke.src
will continue to work the same; e.g., ifsrc: 'search'
was specified, this would be the same assrc: { type: 'search' }
.
8662e543
#1317 Thanks @Andarist! - AllTTypestate
type parameters default to{ value: any; context: TContext }
now and the parametrized type is passed correctly between various types which results in more accurate types involving typestates.
Patch Changes
3ab3f25e
#1285 Thanks @Andarist! - Fixed an issue with initial state of invoked machines being read without custom data passed to them which could lead to a crash when evaluating transient transitions for the initial state.
-
a7da1451
#1290 Thanks @davidkpiano! - The "Attempted to spawn an Actor [...] outside of a service. This will have no effect." warnings are now silenced for "lazily spawned" actors, which are actors that aren't immediately active until the function that creates them are called:// ⚠️ "active" actor - will warn spawn(somePromise); // 🕐 "lazy" actor - won't warn spawn(() => somePromise); // 🕐 machines are also "lazy" - won't warn spawn(someMachine);
It is recommended that all
spawn(...)
-ed actors are lazy, to avoid accidentally initializing them e.g., when readingmachine.initialState
or calculating otherwise pure transitions. In V5, this will be enforced.
c1f3d260
#1317 Thanks @Andarist! - Fixed a type returned by araise
action - it's nowRaiseAction<TEvent> | SendAction<TContext, AnyEventObject, TEvent>
instead ofRaiseAction<TEvent> | SendAction<TContext, TEvent, TEvent>
. This makes it comaptible in a broader range of scenarios.
8270d5a7
#1372 Thanks @christianchown! - Narrowed theServiceConfig
type definition to use a specific event type to prevent compilation errors on strictly-typedMachineOptions
.
01e3e2dc
#1320 Thanks @davidkpiano! - The JSON definition forstateNode.invoke
objects will no longer include theonDone
andonError
transitions, since those transitions are already merged into thetransitions
array. This solves the issue of reviving a serialized machine from JSON, where before, theonDone
andonError
transitions for invocations were wrongly duplicated.