-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Fixed an issue with some exit handlers being executed more than once when stopping a machine #2895
Conversation
…when stopping a machine
🦋 Changeset detectedLatest commit: 74ae6b2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
CodeSee Review Map:Review in an interactive map View more CodeSee Maps Legend |
if (!transition.source) { | ||
transition.exitSet = []; | ||
|
||
// Ensure that root StateNode (machine) is entered | ||
transition.entrySet.push(this); | ||
} |
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 was redundant as in this scenario (when there is no transition.source
- which in turn means "when resolving the initial state") because the exitSet
is already empty and nothing pushes to it AND entrySet
is already resolved with this
in it - so we were always adding a duplicate root to the list here
const subStateNodes: Array< | ||
StateNode<TContext, any, TEvent, TTypestate> | ||
> = subStateKeys.map((subStateKey) => this.getStateNode(subStateKey)); |
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.
Similarly here - the logic that follows this is already pushing this.getStateNode(subStateKey)
to the subStateNodes
so this line here could be dropped to avoid duplicate entries being pushed to the final subStateNodes
subStateNodes.push( | ||
...flatten( | ||
subStateKeys.map((subStateKey) => | ||
this.getStateNode(subStateKey).getStateNodes(stateValue[subStateKey]) | ||
) | ||
) | ||
); |
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.
it's an equivalent to the reduce on the left - I've found it harder to read this reduce with concat so I've just refactored this to push+map
No description provided.