Skip to content

defineEvent

defineEvent<T>(name, payload?): EventDef<T>

Defined in: ecs/event.ts:48

Declare an event type. The bus is double-buffered: an event sent this frame is readable for exactly the next one, so a reader that misses a frame misses the event — events are for this-frame signalling, not a queue.

payload is a default of the shape T, the way a component declares its fields. Optional, and needed only where a @compiled system reads or writes the event: T is erased at run time, so without it nothing on this side can say what layout the compiled code baked in. The compiler asks for it by name and line when a promise depends on it.

T

string

T & object

EventDef<T>