Search the docs

Find a guide, global, type or member

GlobalEmber

events

Subscribe to built-in events (see EventName) and to custom events your scripts declare. Built-in events hand handlers an Event; custom events hand them the fired payload.

Functions

events.on(name: EventName, fn: (event: Event) -> boolean?, options: (boolean | "precise" | EventOptions)?) -> Connection#

Connects a handler. Raises for an unknown event name, or past 256 handlers in total. options is an EventOptions, or true/"precise" for a precise handler. Return false (or call e:cancel()) to cancel a cancellable event.

events.has(name: string) -> boolean#

Whether any script handler is connected to the event.

events.declare(name: string, options: { cancellable: boolean? }?)#

Declares a custom event so it can be connected to and fired. Names are 1 to 64 of letters, digits, _ . : -; at most 256. Raises on a built-in name.

events.fire(name: string, payload: any?) -> boolean#

Fires a declared custom event with a payload of plain data (no functions, nested at most 8 deep). Handlers run later in the host's tick, never inline, so a fire cannot be cancelled. whether anything is listening