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
callback
function
Required
The callback that runs when a process broadcasts a message.
callback(sender)
object
Required
The process that broadcasted the message.
callback(sender.surface)
string
Required
The surface of the process that broadcasted the message.
The possible values are:
"object_panel"
"selected_image_overlay"
callback(sender.processId)
string
Required
The ID of the process that broadcasted the message.
callback(sender.launchParams)
object
Optional
The launch parameters of the process that broadcasted the message.
callback(sender, message)
any
Required
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.