Skip to content

Commit

Permalink
Add changeset for core
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkpiano committed Dec 1, 2020
1 parent 462cac0 commit 6596d0b
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .changeset/bright-zoos-reflect.md
@@ -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>;
}
```

0 comments on commit 6596d0b

Please sign in to comment.