-
-
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.
* Typed input * Cleaning up some types * Add AnythingButAFunction to clean up types * Fix tests * fix type issues * fixed tests * tweak tests * Remove `AnythingButAFunction` * Remove incorrect forwarding of the `TInput` * Introduce `NonReducibleUnknown` * tweak actor types * Add small test for input mapper * Add test for output * Add self to property mapper * Remove property mapper type for output * Simplify mapContext function and add dev-time warning * Add changeset * handle my own nits --------- Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
- Loading branch information
1 parent
ead1e43
commit a247111
Showing
34 changed files
with
467 additions
and
224 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,29 @@ | ||
--- | ||
'xstate': minor | ||
--- | ||
|
||
Input types can now be specified for machines: | ||
|
||
```ts | ||
const emailMachine = createMachine({ | ||
types: {} as { | ||
input: { | ||
subject: string; | ||
message: string; | ||
}; | ||
}, | ||
context: ({ input }) => ({ | ||
// Strongly-typed input! | ||
emailSubject: input.subject, | ||
emailBody: input.message.trim() | ||
}) | ||
}); | ||
|
||
const emailActor = interpret(emailMachine, { | ||
input: { | ||
// Strongly-typed input! | ||
subject: 'Hello, world!', | ||
message: 'This is a test.' | ||
} | ||
}).start(); | ||
``` |
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
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.