Minor Changes
-
36ed8d0a
#1262 Thanks @Andarist! - Improved type inference forInvokeConfig['data']
. This has required renamingdata
property onStateNode
instances todoneData
. This property was never meant to be a part of the public API, so we don't consider this to be a breaking change. -
2c75ab82
#1219 Thanks @davidkpiano! - The resolved value of theinvoke.data
property is now available in the "invoke meta" object, which is passed as the 3rd argument to the service creator inoptions.services
. This will work for all types of invoked services now, including promises, observables, and callbacks.const machine = createMachine({ initial: 'pending', context: { id: 42 }, states: { pending: { invoke: { src: 'fetchUser', data: { userId: (context) => context.id }, onDone: 'success' } }, success: { type: 'final' } } }, { services: { fetchUser: (ctx, _, { data }) => { return fetch(`some/api/user/${data.userId}`) .then(response => response.json()); } } }
-
a6c78ae9
#1249 Thanks @davidkpiano! - New property introduced for eventless (transient) transitions:always
, which indicates a transition that is always taken when in that state. Empty string transition configs for transient transitions are deprecated in favor ofalways
:// ... states: { playing: { + always: [ + { target: 'win', cond: 'didPlayerWin' }, + { target: 'lose', cond: 'didPlayerLose' }, + ], on: { // ⚠️ Deprecation warning - '': [ - { target: 'win', cond: 'didPlayerWin' }, - { target: 'lose', cond: 'didPlayerLose' }, - ] } } } // ...
The old empty string syntax (
'': ...
) will continue to work until V5.