appProcess.current.setOnDispose

API reference for the appProcess.current.setOnDispose method.

Registers a callback that runs when the current process is about to close.

import { appProcess } from "@canva/preview/platform";
appProcess.current.setOnDispose((context) => {
console.log(context.reason); // => "completed"
});
tsx
#callbackfunction
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.

void