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