API reference
Design
addAudioTrackaddElementAtCursoraddElementAtPointaddNativeElementaddPagecreateRichtextRangeeditContentgetCurrentPageContextgetDefaultPageDimensionsgetDesignMetadatagetDesignTokeninitAppElementopenDesignoverlay.registerOnCanOpenrequestExportselection.registerOnChangesetCurrentPageBackgroundui.startDragToCursorui.startDragToPointui.startDrag
Intents: data
Intents: design
Platform
appProcessappProcess.broadcastMessageappProcess.currentappProcess.current.getInfoappProcess.current.requestCloseappProcess.current.setOnDisposeappProcess.requestCloseappProcess.registerOnMessageappProcess.registerOnStateChangefeatures.isSupportedfeatures.registerOnSupportChangegetPlatformInfonotification.addToastrequestOpenExternalUrl
appProcess.registerOnStateChange
API reference for the appProcess.registerOnStateChange method.
Registers a callback that runs when the state of the specified app process changes.
Usage: Listen for process state changes
import { appProcess } from '@canva/platform';const stateDisposer = appProcess.registerOnStateChange(processId,({ state }) => {switch (state) {case 'opening':// Process is starting upbreak;case 'open':// Process is active and visiblebreak;case 'closing':// Process is about to close// Save state, cleanup resourcesbreak;case 'closed':// Process has been terminated// Final cleanup if neededbreak;}});// Later: cleanup the listenerawait stateDisposer();
TYPESCRIPT
Parameters
targetAppProcessIdRequired
The ID of an app process.
callbackOnStateChangeCallbackRequired
The callback to run when the state of the process changes.
Parameters
optsobjectRequired
Information about the state change.
- opts.state - The state of the process.
stateProcessStateRequired
The state of an app process.
The possible states include:
"opening"- The app process is opening."open"- The app process is open, active, and visible on the designated surface."closing"- The app process is closing."closed"- The app process has been closed and is no longer active.
While a process is closing, it won't receive any events or messages from other processes.
Available values:
"opening""open""closing""closed"
Returns
void
Returns
A disposer function that cleans up the registered callback.
() => Promise<void>