Skip to content
KCKingdoms Connected Scripting APIScripting guides and API
Data shapeClient APIGenerated

EventBus

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

Asynchronous resource event bus.

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

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

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:4473

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:4487

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:4458

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:4480

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:4434

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:4441

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:4405

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:4413

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:4420

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:4427

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:4465

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