EventBus
Defined in: client/api.d.ts:9510
Asynchronous resource event bus.
Methods
Section titled “Methods”emit()
Section titled “emit()”emit(
eventName, …args):Promise<void>
Defined in: client/api.d.ts:9561
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:9585
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:9599
Sends a named event from this client to the server’s isolated onClient handlers. Throws a RangeError when the name is over 1 KiB or the payload over 1 MiB.
Parameters
Section titled “Parameters”eventName
Section titled “eventName”string
Server-side client-event name.
payload?
Section titled “payload?”unknown
Optional payload. A string is sent as is and must already be JSON text: the server parses it and drops an event that does not parse. Other values are JSON-serialized. At most 1 MiB once serialized.
Returns
Section titled “Returns”void
emitTo()
Section titled “emitTo()”emitTo(
resourceName,eventName, …args):Promise<void>
Defined in: client/api.d.ts:9570
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:9592
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:9546
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:9553
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:9517
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:9525
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:9532
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:9539
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:9577
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