statelyai / xstate

Actor-based state management & orchestration for complex app logic.
https://stately.ai/docs
MIT License
26.98k stars 1.24k forks source link

Bug: reenter in sibling states #4818

Closed Jfsslemos closed 2 months ago

Jfsslemos commented 6 months ago

XState version

XState version 5

Description

Reenter attribute doesn't work on sibiling states

Expected result

[...] states:{ state1:{ entry: console.log(''state1") on:{ '':{target: 'state2' reenter: true}, }, }, state2:{ entry: console.log(''state2") on:{ '':{target: 'state1' reenter: true}, }, }, } [...]

output: state1 state2 state1 state2 state1 state2 [...]

Actual result

output: state1 state2 and stops here, doesn't reenter in states that are not parent-child

Reproduction

i dont really know how to make those options of reproduction

Additional context

No response

davidkpiano commented 6 months ago

Reentry does not apply here since you are not reentering the same (or ancestor) state.

Jfsslemos commented 6 months ago

But how could I achieve this functionality? Just to be clear, i have no parente-child state, only sibiling states. And I want transition many times to the same state during the execution in a way that every time the state execute it's entry function

Jfsslemos commented 6 months ago

Reentry does not apply here since you are not reentering the same (or ancestor) state.

But how could I achieve this functionality? Just to be clear, i have no parente-child state, only sibiling states. And I want transition many times to the same state during the execution in a way that every time the state execute it's entry function

davidkpiano commented 2 months ago

Closing this as invalid – if you can explain your use-case a bit more, I can help you figure out a better solution. However, reentering is not related to sibling states.