-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Fix SubStates with multiple source states not reacting to all source changes #19595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Fix SubStates with multiple source states not reacting to all source changes #19595
Conversation
…changes - Fix issue where `SubStates` depending on multiple source states would only react when _all_ source states changed simultaneously. - SubStates should be created/destroyed whenever _any_ of their source states transitions, not only when all change together. - Changed the "did parent change" detection logic from AND to OR. We need to check if _any_ of the event readers changed, not if _all_ of them changed. - Add new test.
@benfrankel @MiniaczQ care to review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fix seems correct. I'm curious why the computed states version checks event_reader.is_empty() && ...
while the sub states version checks !(event_reader.read().last().is_some() || ...)
, though. It seems like they're trying to do the same thing.
Yeah I am unsure as well. As you say, the docs for
And the same for
I added a new similar test I'm inclined to not try and change the internals of either though. The two new tests prove the expected behavior and so theoretically they can be refactored in the future as long as the tests still pass. |
Objective
SubStates
depending on multiple source states would only react when all source states changed simultaneously.Solution
||
s not&&
s like this:Testing