Skip to content

EditorBus beta ​

Class of @v12-engine/editor

ts
export declare class EditorBus

The editor's bus (editor.bus): on(name, listener) hears of an event, once of the next one, emit(name, data) sends one to whoever listens, in the order they came. A listener that throws is said in the Console and the rest are still told. listens(name) says whether anything hears of an event, for what costs to work out, and whenListened tells as the first listener of one comes and the last goes, for what is only made while someone listens. What a panel registers through its handle (panel.on) goes with the panel

Members ​

clear ​

ts
clear(): void;

Takes every listener and watcher away: the editor is done with

emit ​

ts
emit<K extends EditorEventName>(name: K, ...data: EditorEventData<K>): void;

Tells whoever listens to that name, in the order they came. Nothing happens for an event nothing listens to

emit ​

ts
emit(name: string, data?: unknown): void;

emit for an event name not in EditorEvents, with optional data

listens ​

ts
listens(name: EditorEventName | (string & {})): boolean;

Whether anything hears of an event: for what would cost to work out for no one

off ​

ts
off(name: string, listener: (data: never) => void): void;

Stops a listener given to on: what on gives back does the same

on ​

ts
on<K extends EditorEventName>(name: K, listener: (data: EditorEvents[K]) => void): () => void;

Hears of every event of that name, from now on. Gives back what stops it

on ​

ts
on(name: string, listener: (data: unknown) => void): () => void;

on for an event name not in EditorEvents; listeners hear its data as unknown

once ​

ts
once<K extends EditorEventName>(name: K, listener: (data: EditorEvents[K]) => void): () => void;

Hears of the next event of that name, once. Gives back what stops it before then

once ​

ts
once(name: string, listener: (data: unknown) => void): () => void;

once for an event name not in EditorEvents; listens one time

whenListened ​

ts
whenListened(name: EditorEventName | (string & {}), watcher: (listened: boolean) => void): () => void;

Told as the first listener of an event comes (true) and as the last goes (false): for what is only worked out while someone listens (the editor's play.tick). Told at once when something listens already. Gives back what stops it