-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
xstate.stop
event and fix exit handlers execution (#3126)
* Add `xstate.stop` event and fix exit handlers execution * Make `state.value` of a stopped state an empty object * Preserve last known `state.value` when service gets stopped * Execute send actions from exit handlers of stopped/done machines * Added changeset * Make exit handlers of a machine that reached a final state be called with the last received event * Tweak wording of the added changeset Co-authored-by: David Khourshid <davidkpiano@gmail.com> Co-authored-by: David Khourshid <davidkpiano@gmail.com>
- Loading branch information
1 parent
186b254
commit 37b751c
Showing
5 changed files
with
577 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'xstate': minor | ||
--- | ||
|
||
All `exit` actions in the machine will now be correctly resolved and executed when a machine gets stopped or reaches its top-level final state. Previously, the actions were not correctly resolved and that was leading to runtime errors. | ||
|
||
To implement this fix in a reliable way, a new internal event has been introduced: `{ type: 'xstate.stop' }` and when the machine stops its execution, all exit handlers of the current state (i.e. the active state nodes) will be called with that event. You should always assume that an exit handler might be called with that event. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.