statelyai / xstate

Actor-based state management & orchestration for complex app logic.
https://stately.ai/docs
MIT License
27.21k stars 1.26k forks source link

Mark events internal to a machine #5026

Open tkvw opened 3 months ago

tkvw commented 3 months ago

Created this issue on request of David following this question on discord

Feature request/Typescript

I am using a callback actor which uses sendBack to the parent machine, but to handle the events in the machine I need to add the events in the setup events type. This is fine, but will also expose these events as being valid events to be send to the machine by an outside actor. Maybe an additional type internalEvents on the setup type? something like:

type TEvents = ..
type TInternalEvents = TEvents | ...
setup({
   types: {} as {
       events: TEvents,
       internalEvents: TInternalEvents
   }
})