-
-
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.
Move machine's
output
to top level (#4306)
* Move machine's `output` to top level * Fixed one of the test files * fixed rest of the tests * Changeset WIP * Add warning for missing top-level output (#4313) * Add warning * Update packages/core/test/json.test.ts Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> * tweak a test case * tweak code --------- Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> * tweak changeset --------- Co-authored-by: David Khourshid <davidkpiano@gmail.com>
- Loading branch information
1 parent
0c7b3aa
commit 30e3cb2
Showing
14 changed files
with
211 additions
and
243 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,30 @@ | ||
--- | ||
'xstate': major | ||
--- | ||
|
||
The final `output` of a state machine is now specified directly in the `output` property of the machine config: | ||
|
||
```ts | ||
const machine = createMachine({ | ||
initial: 'started', | ||
states: { | ||
started: { | ||
// ... | ||
}, | ||
finished: { | ||
type: 'final' | ||
// moved to the top level | ||
// | ||
// output: { | ||
// status: 200 | ||
// } | ||
} | ||
}, | ||
// This will be the final output of the machine | ||
// present on `snapshot.output` and in the done events received by the parent | ||
// when the machine reaches the top-level final state ("finished") | ||
output: { | ||
status: 200 | ||
} | ||
}); | ||
``` |
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
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.