Skip to content

Commit

Permalink
feat: restrict invoked subscribable to eventobject
Browse files Browse the repository at this point in the history
BREAKING

Signed-off-by: Wouter Termont <woutermont@gmail.com>
  • Loading branch information
woutermont committed Apr 15, 2021
1 parent 14cdef6 commit 18789aa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions .changeset/gorgeous-kiwis-drive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
'xstate': major
---

This update restricts invoked `Subscribable`s to `EventObject`s,
so that type inference can be done on which `Subscribable`s are
allowed to be invoked.

Existing `MachineConfig`s that invoke `Subscribable`s that are not
`Subscribable<EventObject>`s should be updated accordingly:
either their emissions are desired, and should thus be acted on
as events, or they are not, in which case an action would
probably be a better choice than a service.
2 changes: 1 addition & 1 deletion packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ export type InvokeCreator<
) =>
| PromiseLike<TFinalContext>
| StateMachine<TFinalContext, any, any>
| Subscribable<any>
| Subscribable<EventObject>
| InvokeCallback;

export interface InvokeDefinition<TContext, TEvent extends EventObject>
Expand Down

0 comments on commit 18789aa

Please sign in to comment.