Skip to content

v3.2.0

Compare
Choose a tag to compare
@davidkpiano davidkpiano released this 28 Apr 07:07
· 6338 commits to main since this release

Plenty of new improvements and features in this release! 🎉

  • Support for metadata in state nodes, which are returned in the resulting State object. #45
{
  green: {
	on: { /* ... */ },
	data: {
	  name: 'Green Light'
	}
  }
}
  • Transient states (with eventless transitions) and conditional transition arrays supported. #43
  const myMachine = Machine({
    initial: 'G',
    parallel: false,
    states: {
      G: {
        on: { UPDATE_BUTTON_CLICKED: 'E' }
      },
      E: {
        on: {
          // eventless transition
          '': [
            { target: 'D', cond: ({ data }) => !data }, // no data returned
            { target: 'B', cond: ({ status }) => status === 'Y' },
            { target: 'C', cond: ({ status }) => status === 'X' },
            { target: 'F' } // default, or just the string 'F'
          ]
        }
      },
      D: {},
      B: {},
      C: {},
      F: {}
    }
  });
  • Partial support for SCXML conversion - full support coming 🔜
  • State nodes can now be targeted directly via ID.
    • A state node can have the id: 'foobar' prop, for example
    • A transition can target that ID via { target: '#foobar' } (or just '#foobar').
  • IDs can also be passed directly to machine.transition('#some-id', 'EVENT').
  • Partial support for internal (local) transitions, using .childState syntax. See #71
  • Multiple targets supported with array syntax, e.g., { target: ['foo.bar.one', 'foo.baz.quo'] }. #80
  • Just like conditions, now you can used named functions as actions instead of just strings!
  • matchesState will now return false if the parent state is more specific than the child state. #69