On September 25th, 2024, we released v2 of the Apps SDK. To learn what’s new and how to upgrade, see Migration FAQ and Migration guide.

appProcess.registerOnStateChange

API reference for the appProcess.registerOnStateChange 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 the state of a process changes.

Usage

import { appProcess } from "@canva/platform";
appProcess.current.registerOnStateChange("ID GOES HERE", (context) => {
console.log(context.state); // => "open"
});
TSX

Parameters

targetstringRequired

The ID of a process.

callbackfunctionRequired

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

callback(context)objectRequired

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

callback(context.state)stringRequired

The state of the process.

The possible values are:

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

Returns

A disposer function that cleans up the registered callback.