EventBus
Defined in: client/api.d.ts:4398
Asynchronous resource event bus.
Methods
Section titled “Methods”emit()
Section titled “emit()”emit(
eventName, …args):Promise<void>
Defined in: client/api.d.ts:4449
Invokes every shared handler and waits for all synchronous and asynchronous results.
Parameters
Section titled “Parameters”eventName
Section titled “eventName”string
Shared event name.
…unknown[]
Arguments delivered to every matching handler.
Returns
Section titled “Returns”Promise<void>
Promise rejected with an AggregateError when one or more handlers fail.
emitLocal()
Section titled “emitLocal()”emitLocal(
eventName, …args):Promise<void>
Defined in: client/api.d.ts:4473
Emits an event only within the calling resource.
Parameters
Section titled “Parameters”eventName
Section titled “eventName”string
Private local event name.
…unknown[]
Arguments delivered only to handlers owned by the calling resource.
Returns
Section titled “Returns”Promise<void>
Promise rejected when one or more local handlers fail.
emitServer()
Section titled “emitServer()”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.
Parameters
Section titled “Parameters”eventName
Section titled “eventName”string
Server-side client-event name.
payload?
Section titled “payload?”unknown
Optional string payload sent verbatim; other values are JSON-serialized.
Returns
Section titled “Returns”void
emitTo()
Section titled “emitTo()”emitTo(
resourceName,eventName, …args):Promise<void>
Defined in: client/api.d.ts:4458
Invokes matching handlers belonging only to one resource.
Parameters
Section titled “Parameters”resourceName
Section titled “resourceName”string
Destination running resource.
eventName
Section titled “eventName”string
Shared event name.
…unknown[]
Arguments delivered to matching handlers owned by the destination.
Returns
Section titled “Returns”Promise<void>
Promise rejected when one or more destination handlers fail.
listenerCount()
Section titled “listenerCount()”listenerCount(
eventName):number
Defined in: client/api.d.ts:4480
Counts persistent and one-shot shared handlers across resources.
Parameters
Section titled “Parameters”eventName
Section titled “eventName”string
Shared event name to inspect.
Returns
Section titled “Returns”number
Number of matching handlers.
Call Signature
Section titled “Call Signature”off<
K>(eventName,handler):void
Defined in: client/api.d.ts:4434
Removes a matching handler owned by the calling resource.
Type Parameters
Section titled “Type Parameters”K extends keyof EventMap
Parameters
Section titled “Parameters”eventName
Section titled “eventName”K
Case-sensitive event name.
handler
Section titled “handler”(…args) => unknown
Resource-owned callback invoked with the emitted arguments.
Returns
Section titled “Returns”void
Call Signature
Section titled “Call Signature”off(
eventName,handler):void
Defined in: client/api.d.ts:4441
Removes a matching handler owned by the calling resource.
Parameters
Section titled “Parameters”eventName
Section titled “eventName”string
Case-sensitive event name.
handler
Section titled “handler”Resource-owned callback invoked with the emitted arguments.
Returns
Section titled “Returns”void
Call Signature
Section titled “Call Signature”on<
K>(eventName,handler):Unsubscribe
Defined in: client/api.d.ts:4405
Registers a persistent handler in the shared event namespace.
Type Parameters
Section titled “Type Parameters”K extends keyof EventMap
Parameters
Section titled “Parameters”eventName
Section titled “eventName”K
Case-sensitive event name.
handler
Section titled “handler”(…args) => unknown
Resource-owned callback invoked with the emitted arguments.
Returns
Section titled “Returns”Function that removes this exact subscription.
Call Signature
Section titled “Call Signature”on(
eventName,handler):Unsubscribe
Defined in: client/api.d.ts:4413
Registers a persistent handler in the shared event namespace.
Parameters
Section titled “Parameters”eventName
Section titled “eventName”string
Case-sensitive event name.
handler
Section titled “handler”Resource-owned callback invoked with the emitted arguments.
Returns
Section titled “Returns”Function that removes this exact subscription.
once()
Section titled “once()”Call Signature
Section titled “Call Signature”once<
K>(eventName,handler):void
Defined in: client/api.d.ts:4420
Registers a handler that is removed before its first invocation.
Type Parameters
Section titled “Type Parameters”K extends keyof EventMap
Parameters
Section titled “Parameters”eventName
Section titled “eventName”K
Case-sensitive event name.
handler
Section titled “handler”(…args) => unknown
Resource-owned callback invoked with the emitted arguments.
Returns
Section titled “Returns”void
Call Signature
Section titled “Call Signature”once(
eventName,handler):void
Defined in: client/api.d.ts:4427
Registers a handler that is removed before its first invocation.
Parameters
Section titled “Parameters”eventName
Section titled “eventName”string
Case-sensitive event name.
handler
Section titled “handler”Resource-owned callback invoked with the emitted arguments.
Returns
Section titled “Returns”void
onLocal()
Section titled “onLocal()”onLocal(
eventName,handler):void
Defined in: client/api.d.ts:4465
Registers a handler in the calling resource’s private local-event namespace.
Parameters
Section titled “Parameters”eventName
Section titled “eventName”string
Case-sensitive event name.
handler
Section titled “handler”Resource-owned callback invoked with the emitted arguments.
Returns
Section titled “Returns”void