- đŦ Sending events with payloads to running services just got a lot easier. You can now specify two arguments:
eventType
(string)payload
(object)
service.send('EVENT', { foo: 'bar' });
// equivalent to...
service.send({ type: 'EVENT', foo: 'bar' });
This is similar to how Vuex allows you to send events. #408
- â You can now send batch events in a running service:
someService.send([
'SOME_EVENT', // simple events
'ANOTHER_EVENT',
{ type: 'YET_ANOTHER_EVENT', data: [1, 2, 3] } // event objects
]);
Actions from each state will be bound to a snapshot of their state at the time of their creation, and execution is deferred until all events are processed (in essentially zero-time). #409
- đĒ To avoid confusion,
onEntry
andonExit
have been aliased toentry
andexit
, respectively:
// ...
{
- onEntry: 'doSomething',
+ entry: 'doSomething',
- onExit: 'doSomethingElse',
+ exit: 'doSomethingElse'
}
The onEntry
and onExit
properties still work, and are not deprecated in this major version.
- đē Instead of just
true
orfalse
for theactivities
mapping inState
objects, a truthy activity actually gives you the full activity definition. - âą Proper scheduler work eliminates many edge-cases and issues with sync/async event processing, thanks to @jjkola #392
- đ¤ Thanks to @johnyanarella, invoking promises will work with promise-like values in case non-native promises are used. #415 #417
- đŠâđĢ The
Interpreter
class is exposed in the main exports. - đ New package:
@xstate/immer
coming soon! More info on this đ
Docs
- âī¸ In the examples,
ctx
is spelled out tocontext
ande
toevent
in order to improve readability and comprehension. - đ The RxJS docs đ were updated to address #339
- đ The internal transition docs moved into the transitions docs đ.
- âšī¸ New pages: About đ and Goals đ (more to be added đ)
- đ Docs were added for relative targets (shortcut syntax) in ids đ and transitions đ
- âĒ Docs on restarting activities đ were added
- đĩī¸ââī¸ The
options
argument was missing in theuseMachine
implementation in the React docs đ - that's been fixed đ