npm xstate 4.5.0

latest releases: 4.33.0, 5.0.0-alpha.0, 4.32.1...
3 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:
  'SOME_EVENT', // simple events
  { 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 🔜


Don't miss a new xstate release

NewReleases is sending notifications on new releases.