appProcess.registerOnMessage

API reference for the appProcess.registerOnMessage method.

Registers a callback that runs when a process broadcasts a message.

import { appProcess } from "@canvas/preview/platform";
appProcess.registerOnMessage((sender, message) => {
console.log(sender);
console.log(message);
});
tsx
#callbackfunction
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).

void