Skip to content

Commit

Permalink
Add changeset
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkpiano committed Jun 7, 2021
1 parent 7377971 commit 99bc5fb
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
28 changes: 28 additions & 0 deletions .changeset/dirty-points-reply.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
'xstate': patch
---

The `SpawnedActorRef` TypeScript interface has been deprecated in favor of a unified `ActorRef` interface, which contains the following:

```ts
interface ActorRef<TEvent extends EventObject, TEmitted = any>
extends Subscribable<TEmitted> {
send: (event: TEvent) => void;
id: string;
subscribe(observer: Observer<T>): Subscription;
subscribe(
next: (value: T) => void,
error?: (error: any) => void,
complete?: () => void
): Subscription;
getSnapshot: () => TEmitted | undefined;
}
```

For simpler actor-ref-like objects, the `BaseActorRef<TEvent>` interface has been introduced.

```ts
interface BaseActorRef<TEvent extends EventObject> {
send: (event: TEvent) => void;
}
```
6 changes: 3 additions & 3 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export interface ActivityDefinition<TContext, TEvent extends EventObject>
type: string;
}

export type Sender<TEvent extends EventObject> = (event: Event<TEvent>) => void;
export type Sender<TEvent extends EventObject> = (event: TEvent) => void;

type ExcludeType<A> = { [K in Exclude<keyof A, 'type'>]: A[K] };

Expand Down Expand Up @@ -1280,12 +1280,12 @@ export type ExtractEvent<
> = TEvent extends { type: TEventType } ? TEvent : never;

export interface BaseActorRef<TEvent extends EventObject> {
send: Sender<TEvent>;
send: (event: TEvent) => void;
}

export interface ActorRef<TEvent extends EventObject, TEmitted = any>
extends Subscribable<TEmitted> {
send: Sender<TEvent>;
send: Sender<TEvent>; // TODO: this should just be TEvent
id: string;
getSnapshot: () => TEmitted | undefined;
stop?: () => void;
Expand Down

0 comments on commit 99bc5fb

Please sign in to comment.