appProcess.registerOnStateChange

API reference for the appProcess.registerOnStateChange method.

Registers a callback that runs when the state of a process changes.

import { appProcess } from "@canva/preview/platform";
appProcess.current.registerOnStageChange("ID GOES HERE", (context) => {
console.log(context.state); // => "open"
});
tsx
#targetstring
Required

The ID of a process.

#callbackfunction
Required

The callback to run when the state of the process changes.

#callback(context)object
Required

Information passed to the callback when the state of the process changes.

#callback(context.state)string
Required

The state of the process.

The possible values are:

  • "opening"
  • "open"
  • "closing"
  • "closed"

Promise<void>