Skip to content

Releases: statelyai/xstate

@xstate/[email protected]

24 Jan 10:53
Compare
Choose a tag to compare

Minor Changes

  • 7367de2 #946 Thanks @Andarist! - Added a second, optional, options parameter to the createMachine. Currently only actions map can be put there - similarly how this can be done for xstate itself:

    Example
    const machine = createMachine({
      initial: 'idle'
      states: {
        idle: {
          on: {
            LOAD: {
              target: 'loading',
              actions: 'fetchData'
            }
          }
        },
        loading: {
          // ...
        }
      }
    }, {
      actions: {
        fetchData: () => /* ... */
      }
    })
  • 3c10215 #811 Thanks @ghengeveld! - A config property got exposed on created machines. It's the same object which got passed in as argument.

Patch Changes

  • a337473 #827 Thanks @Andarist! - Fixed entry actions defined on an initial state not being executed.

[email protected]

07 Jan 15:41
d592b36
Compare
Choose a tag to compare

Patch Changes

  • dae8818: Typestates are now propagated to interpreted services.

@xstate/[email protected]

07 Jan 15:41
d592b36
Compare
Choose a tag to compare

Minor Changes

  • 1405754: Options for testModel.getCoverage() and testModel.testCoverage() can now be provided to filter which state nodes should be covered by the tests.

Patch Changes

@xstate/[email protected]

07 Jan 15:41
d592b36
Compare
Choose a tag to compare

Minor Changes

  • 3cda398: The assign() action creator is now strongly-typed, and takes the context and event types as generic parameters, just like in XState core.
  • 61ccfbd: Make interpret default for TEvent type parameter more strict. It's now EventObject instead of any and it matches the default on createMachine.

Patch Changes

[email protected]

28 Dec 22:06
be2bc0d
Compare
Choose a tag to compare

Patch Changes

  • 6b3d767: Fixed issue with delayed transitions scheduling a delayed event for each transition defined for a single delay.

@xstate/[email protected]

28 Dec 22:06
be2bc0d
Compare
Choose a tag to compare

Patch Changes

v4.7.0

30 Nov 15:44
Compare
Choose a tag to compare
  • 🐌 If a subscriber/listener subscribes to a service that is already running, it will now receive the current state upon subscription. #814
  • 🆙 The new escalate() action creator escalates custom error events to a parent machine, which can catch those in the onError transition:
import { createMachine, actions } from 'xstate';
const { escalate } = actions;

const childMachine = createMachine({
  // ...
  // This will be sent to the parent machine that invokes this child
  entry: escalate({ message: 'This is some error' })
});

const parentMachine = createMachine({
  // ...
  invoke: {
    src: childMachine,
    onError: {
      actions: (context, event) => {
        console.log(event.data);
        //  {
        //    type: ...,
        //    data: {
        //      message: 'This is some error'
        //    }
        //  }
      }
    }
  }
});
  • ❓ You can now specify undefined as the first argument for machine.transition(...), which will default to the initial state:
lightMachine.transition(undefined, 'TIMER').value;
// => 'yellow'
  • 🤝 Services (invoked machines) are now fully subscribable and can interop with libraries that implement TC39 Observbles like RxJS. See https://xstate.js.org/docs/recipes/rxjs.html for more info.

  • 🆔 When a service is invoked, it has a uniquely generated sessionId, which corresponds to _sessionid in SCXML. This ID is now available directly on the state object to identify which service invocation the state came from: state._sessionid #523

  • ⚙️ The original config object passed to Machine(config) (or createMachine(config)) is now the exact same object reference in the resulting machine.config property.

  • 🎰 The createMachine() factory function now exists and is largely the same as Machine(), except with a couple differences:

    • The generic type signature is <TContext, TEvent, TState> instead of <TContext, TStateSchema, TEvent>.
    • There is no third argument for specifying an initial context. Use .withContext(...) on the machine or return a machine with the expected context in a factory instead.
  • 🛑 Event sent to a stopped service will no longer execute any actions, nor have any effect. #735

  • 🚸 The invoked actors are now directly available on state.children.

  • ✍️ Plain strings can now be logged in the log() action creator:

entry: log('entered here', 'some label')
const quietMachine = Machine({
  id: 'quiet',
  initial: 'idle',
  states: {
    idle: {
      on: {
        WHISPER: undefined,
        // On any event besides a WHISPER, transition to the 'disturbed' state
        '*': 'disturbed'
      }
    },
    disturbed: {}
  }
});

quietMachine.transition(quietMachine.initialState, 'WHISPER');
// => State { value: 'idle' }

quietMachine.transition(quietMachine.initialState, 'SOME_EVENT');
// => State { value: 'disturbed' }

v4.6.7

12 Jul 20:08
Compare
Choose a tag to compare
  • A regression in the new stateUtils.ts file caused a bundling failure; this is now fixed.

v4.6.6

12 Jul 20:08
Compare
Choose a tag to compare
  • A configuration change that included testing files as an included path in tsconfig.json was reverted.

v4.6.5

12 Jul 20:07
Compare
Choose a tag to compare

Improvements

  • The service.children property of interpreter instances is now marked as public.
  • An improved algorithm for determining state nodes on a transition fixed #518. This algorithm will eventually replace the current one, while maintaining the same behavior.
  • spawn() is now typed correctly. #521