github statelyai/xstate xstate@4.19.0

3 years ago

Minor Changes

  • 4f2f626d #2143 Thanks @davidkpiano! - Tags can now be added to state node configs under the .tags property:

    const machine = createMachine({
      initial: 'green',
      states: {
        green: {
          tags: 'go' // single tag
        },
        yellow: {
          tags: 'go'
        },
        red: {
          tags: ['stop', 'other'] // multiple tags
        }
      }
    });

    You can query whether a state has a tag via state.hasTag(tag):

    const canGo = state.hasTag('go');
    // => `true` if in 'green' or 'yellow' state

Patch Changes

  • a61d01ce #2125 Thanks @VanTanev! - In callback invokes, the types of callback and onReceive are properly scoped to the machine TEvent.

Don't miss a new xstate release

NewReleases is sending notifications on new releases.