This repository was archived by the owner on Mar 5, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 12
Callback services not typed correctly #89
Copy link
Copy link
Open
Description
The definitions for InvokeCallback and InvokeCreator are currently:
export type InvokeCallback<
TEvent extends EventObject = AnyEventObject,
TSentEvent extends EventObject = AnyEventObject
> = (
callback: Sender<TSentEvent>,
onReceive: Receiver<TEvent>
) => (() => void) | Promise<any> | void;
export type InvokeCreator<
TContext,
TEvent extends EventObject,
TFinalContext = any
> = (
context: TContext,
event: TEvent,
meta: InvokeMeta
) =>
| PromiseLike<TFinalContext>
| StateMachine<TFinalContext, any, any>
| Subscribable<EventObject>
| InvokeCallback<any, TEvent>;
xstate-codegen narrows the event type down to the event that caused the transition and invoked the service. This makes the event type for the Sender in the InvokeCallback the same. It should be able to send any of the machine's events back to it, regardless of what event caused the service to be invoked.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels