github statelyai/xstate v4.5.0

latest releases: @xstate/vue@4.0.0, @xstate/store@2.6.1, @xstate/svelte@4.0.0...
5 years ago
  • đŸ“Ŧ 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 and onExit have been aliased to entry and exit, 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 or false for the activities mapping in State 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

Don't miss a new xstate release

NewReleases is sending notifications on new releases.