Messages
constMessages:object
Defined in: client/api.d.ts:2031
Typed request and notification channel between local resources through the global Messages object.
Type Declaration
Section titled “Type Declaration”handle()
Section titled “handle()”handle(
messageType,handler):void
Registers or replaces a message handler owned by the calling resource.
Parameters
Section titled “Parameters”messageType
Section titled “messageType”string
Message type unique within the receiving resource.
handler
Section titled “handler”MessageHandler
Handler invoked with the payload and a reply callback; the reply is ignored for notifications.
Returns
Section titled “Returns”void
request()
Section titled “request()”request(
resourceName,messageType,payload?):Promise<unknown>
Sends a request to another local resource and waits for its handler to call reply.
Parameters
Section titled “Parameters”resourceName
Section titled “resourceName”string
Destination running resource.
messageType
Section titled “messageType”string
Handler type registered by the destination.
payload?
Section titled “payload?”unknown
Optional payload delivered to the handler.
Returns
Section titled “Returns”Promise<unknown>
Promise resolved with the reply value or rejected when delivery or handling fails.
send()
Section titled “send()”send(
resourceName,messageType,payload?):void
Sends a fire-and-forget notification to another local resource.
Parameters
Section titled “Parameters”resourceName
Section titled “resourceName”string
Destination running resource.
messageType
Section titled “messageType”string
Handler type registered by the destination.
payload?
Section titled “payload?”unknown
Optional payload delivered to the handler.
Returns
Section titled “Returns”void
