xstate-viz icon indicating copy to clipboard operation
xstate-viz copied to clipboard

The order of guarded transitions is misleading

Open florianLepretre opened this issue 4 years ago • 0 comments

The order of the guards as implemented in the code is not understandable in the state chart, when using multiple guards in guarded transitions.

For example, this code:

states: {
    foo: {
      on: {
        BAR: [
          { target: "one", cond: "isFirst" },
          { target: "two", cond: "isSecond" },
          { target: "three" },
        ],
      },
    },
    ...

... produces the following state chart, which gives the misleading impression that guards will be executed in a weird order:

image

Full code: https://stately.ai/viz/a31ea271-a4b5-4153-b660-4e59d2bd11e1.

florianLepretre avatar Oct 14 '21 07:10 florianLepretre