xstate icon indicating copy to clipboard operation
xstate copied to clipboard

Mark events internal to a machine

Open tkvw opened this issue 1 year ago • 1 comments

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
   }
})

tkvw avatar Aug 09 '24 06:08 tkvw

That would be a great thing to have. For now I'm using a convention where the interval events start with an underscore.

type Events = 
	| { type: "Public" }
	| { type: "_Private" }

But being able to define them separately would be a way to enforce that they are not used when a machine is shared with 3rd party users.

Hebilicious avatar Dec 13 '24 14:12 Hebilicious