API reference
Design
Platform
appProcess.current.setOnDispose
API reference for the appProcess.current.setOnDispose 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 current process is about to close.
Usage
import { appProcess } from "@canva/platform";appProcess.current.setOnDispose((context) => {console.log(context.reason); // => "completed"});
TSX
Parameters
callback
function
REQUIRED
The callback to run before the current process closes.
callback(context)
object
REQUIRED
Information passed to the callback before the current process closes.
callback(context.reason)
string
REQUIRED
The reason the current process closed.
The possible values are:
"completed"
- Indicates that a workflow is complete, and any unsaved changes should be saved."aborted"
- Indicates that a workflow has been aborted, and unsaved changes should be ignored.
Returns
A disposer function that cleans up the registered callback.