Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
462cac0
commit 6596d0b
Showing
1 changed file
with
38 additions
and
0 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,38 @@ | ||
--- | ||
'xstate': minor | ||
--- | ||
|
||
Spawned/invoked actors and interpreters are now typed as extending `ActorRef` (e.g., `SpawnedActorRef`) rather than `Actor` or `Interpreter`. This unification of types should make it more straightforward to provide actor types: | ||
|
||
```diff | ||
import { | ||
- Actor | ||
+ ActorRef | ||
} from 'xstate'; | ||
|
||
// ... | ||
|
||
interface SomeContext { | ||
- server?: Actor; | ||
+ server?: ActorRef<ServerEvent>; | ||
} | ||
``` | ||
|
||
It's also easier to specify the type of a spawned/invoked machine with `ActorRefFrom`: | ||
|
||
```diff | ||
import { | ||
createMachine, | ||
- Actor | ||
+ ActorRefFrom | ||
} from 'xstate'; | ||
|
||
const serverMachine = createMachine<ServerContext, ServerEvent>({ | ||
// ... | ||
}); | ||
|
||
interface SomeContext { | ||
- server?: Actor; // difficult to type | ||
+ server?: ActorRefFrom<typeof serverMachine>; | ||
} | ||
``` |