API reference
Design
Platform
appProcess.registerOnMessage
API reference for the appProcess.registerOnMessage method.
This version of the API is deprecated. This version will soon be unsupported. You should use a stable version of the API in your app.
Registers a callback that runs when a process broadcasts a message.
Usage
import { appProcess } from "@canvas/platform";appProcess.registerOnMessage(async (sender, message) => {console.log(sender);console.log(message);});
TSX
Parameters
callbackfunctionRequired
The callback that runs when a process broadcasts a message.
callback(sender)objectRequired
The process that broadcasted the message.
callback(sender.surface)stringRequired
The surface of the process that broadcasted the message.
The possible values are:
"object_panel""selected_image_overlay"
callback(sender.processId)stringRequired
The ID of the process that broadcasted the message.
callback(sender.launchParams)objectOptional
The launch parameters of the process that broadcasted the message.
callback(sender, message)anyRequired
The message broadcasted by the process. This can be a primitive value (e.g. a boolean), a literal (e.g. a string), or a more complex value (e.g. a deeply nested object).
Returns
A disposer function that cleans up the registered callback.