Skip to content
M2O Scripting APIScripting reference
Data shapeClient APIGenerated

EventBus

Defined in: client/api.d.ts:2862

Asynchronous resource event bus.

emit(eventName, …args): Promise<void>

Defined in: client/api.d.ts:2913

Invokes every shared handler and waits for all synchronous and asynchronous results.

string

Shared event name.

…unknown[]

Arguments delivered to every matching handler.

Promise<void>

Promise rejected with an AggregateError when one or more handlers fail.


emitLocal(eventName, …args): Promise<void>

Defined in: client/api.d.ts:2937

Emits an event only within the calling resource.

string

Private local event name.

…unknown[]

Arguments delivered only to handlers owned by the calling resource.

Promise<void>

Promise rejected when one or more local handlers fail.


emitServer(eventName, payload?): void

Defined in: client/api.d.ts:2951

Sends a named event from this client to the server’s isolated onClient handlers.

string

Server-side client-event name.

unknown

Optional string payload sent verbatim; other values are JSON-serialized.

void


emitTo(resourceName, eventName, …args): Promise<void>

Defined in: client/api.d.ts:2922

Invokes matching handlers belonging only to one resource.

string

Destination running resource.

string

Shared event name.

…unknown[]

Arguments delivered to matching handlers owned by the destination.

Promise<void>

Promise rejected when one or more destination handlers fail.


listenerCount(eventName): number

Defined in: client/api.d.ts:2944

Counts persistent and one-shot shared handlers across resources.

string

Shared event name to inspect.

number

Number of matching handlers.


off<K>(eventName, handler): void

Defined in: client/api.d.ts:2898

Removes a matching handler owned by the calling resource.

K extends keyof EventMap

K

Case-sensitive event name.

(…args) => unknown

Resource-owned callback invoked with the emitted arguments.

void

off(eventName, handler): void

Defined in: client/api.d.ts:2905

Removes a matching handler owned by the calling resource.

string

Case-sensitive event name.

EventHandler

Resource-owned callback invoked with the emitted arguments.

void


on<K>(eventName, handler): Unsubscribe

Defined in: client/api.d.ts:2869

Registers a persistent handler in the shared event namespace.

K extends keyof EventMap

K

Case-sensitive event name.

(…args) => unknown

Resource-owned callback invoked with the emitted arguments.

Unsubscribe

Function that removes this exact subscription.

on(eventName, handler): Unsubscribe

Defined in: client/api.d.ts:2877

Registers a persistent handler in the shared event namespace.

string

Case-sensitive event name.

EventHandler

Resource-owned callback invoked with the emitted arguments.

Unsubscribe

Function that removes this exact subscription.


once<K>(eventName, handler): void

Defined in: client/api.d.ts:2884

Registers a handler that is removed before its first invocation.

K extends keyof EventMap

K

Case-sensitive event name.

(…args) => unknown

Resource-owned callback invoked with the emitted arguments.

void

once(eventName, handler): void

Defined in: client/api.d.ts:2891

Registers a handler that is removed before its first invocation.

string

Case-sensitive event name.

EventHandler

Resource-owned callback invoked with the emitted arguments.

void


onLocal(eventName, handler): void

Defined in: client/api.d.ts:2929

Registers a handler in the calling resource’s private local-event namespace.

string

Case-sensitive event name.

EventHandler

Resource-owned callback invoked with the emitted arguments.

void