xstate icon indicating copy to clipboard operation
xstate copied to clipboard

[v5] Improve target resolution

Open davidkpiano opened this issue 3 years ago • 4 comments

This PR improves target resolution:

  • Targeting sibling nodes from the root is no longer valid, since the root node has no siblings
createMachine({
  id: 'direction',
  initial: 'left',
  states: {
    left: {},
    right: {}
  },
  on: {
-   LEFT_CLICK: 'left',
+   LEFT_CLICK: '.left'
  }
});
  • Delimiters in state node IDs resolve to the state node from the path relative to the resolved state node ID
createMachine({
  // ...
  on: {
    SOME_EVENT: '#foo.bar' // resolves to whatever.bar
  },
  states: {
    whatever: {
      id: 'foo',
      states: {
        bar: {} // resolves to this state node
      }
    }
  }
});

Closes #500

davidkpiano avatar Dec 19 '21 16:12 davidkpiano

🦋 Changeset detected

Latest commit: c26249236064e46cabd110297f7c3da8e47e7d9b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
xstate Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

changeset-bot[bot] avatar Dec 19 '21 16:12 changeset-bot[bot]

👇 Click on the image for a new way to code review

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map legend

ghost avatar Dec 19 '21 16:12 ghost

Gonna test this asap - I've tried to do so a few days ago but the test output is spammed with some unrelated stuff and this made playing with it a little bit harder. Gonna take a second look on Monday or so and also I will try to clean up that test output.

Andarist avatar Jan 02 '22 12:01 Andarist

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit c26249236064e46cabd110297f7c3da8e47e7d9b:

Sandbox Source
XState Example Template Configuration
XState React Template Configuration

codesandbox-ci[bot] avatar Mar 04 '22 05:03 codesandbox-ci[bot]