Minor Changes
-
7dc7ceb8
#2379 Thanks @davidkpiano! - There is a new.preserveActionOrder
(default:false
) setting in the machine configuration that preserves the order of actions when set totrue
. Normally, actions are executed in order except forassign(...)
actions, which are prioritized and executed first. When.preserveActionOrder
is set totrue
,assign(...)
actions will not be prioritized, and will instead run in order. As a result, actions will capture the intermediatecontext
values instead of the resultingcontext
value from allassign(...)
actions.// With `.preserveActionOrder: true` const machine = createMachine({ context: { count: 0 }, entry: [ ctx => console.log(ctx.count), // 0 assign({ count: ctx => ctx.count + 1 }), ctx => console.log(ctx.count), // 1 assign({ count: ctx => ctx.count + 1 }), ctx => console.log(ctx.count) // 2 ], preserveActionOrder: true }); // With `.preserveActionOrder: false` (default) const machine = createMachine({ context: { count: 0 }, entry: [ ctx => console.log(ctx.count), // 2 assign({ count: ctx => ctx.count + 1 }), ctx => console.log(ctx.count), // 2 assign({ count: ctx => ctx.count + 1 }), ctx => console.log(ctx.count) // 2 ] // preserveActionOrder: false });
Patch Changes
-
4e305372
#2361 Thanks @woutermont! - Add type forSymbol.observable
to theInterpreter
to improve the compatibility with RxJS. -
1def6cf6
#2374 Thanks @davidkpiano! - Existing actors can now be identified inspawn(...)
calls by providing anid
. This allows them to be referenced by string:const machine = createMachine({ context: () => ({ someRef: spawn(someExistingRef, 'something') }), on: { SOME_EVENT: { actions: send('AN_EVENT', { to: 'something' }) } } });
-
da6861e3
#2391 Thanks @davidkpiano! - There are two new helper types for extractingcontext
andevent
types:ContextFrom<T>
which extracts thecontext
from any type that uses contextEventFrom<T>
which extracts theevent
type (which extendsEventObject
) from any type which uses events