API reference
Design
addAudioTrackaddElementAtCursoraddElementAtPointaddNativeElementaddPagecreateRichtextRangeeditContentgetCurrentPageContextgetDefaultPageDimensionsgetDesignMetadatagetDesignTokeninitAppElementoverlay.registerOnCanOpenopenDesignrequestExportselection.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.requestClose
API reference for the appProcess.requestClose method.
This version of the API is a preview. Preview APIs are unstable and may change without warning. You can't release public apps using this API until it's stable.
Requests the termination of the specified app process.
Once called, this method:
- Transitions the state of the process to
"closing"
. - Invokes all registered
setOnDispose
callbacks. - Waits for the process to finish closing.
- Transitions the state of the process to
"closed"
.
Each time the state changes, all of the registerOnStateChange
callbacks are called.
Usage
Close a process
import { appProcess, type AppProcessId } from '@canva/platform';const placeholderProcessId = "PLACEHOLDER_PROCESS_ID" as AppProcessId;await appProcess.requestClose(placeholderProcessId, { reason: 'completed' });
TYPESCRIPT
Pass structured data to a process as it closes
import { appProcess, type AppProcessId, type CloseParams } from '@canva/platform';type DetailedCloseParams = CloseParams & {savePoint: string;timestamp: number;userInitiated: boolean;};const placeholderProcessId = "PLACEHOLDER_PROCESS_ID" as AppProcessId;await appProcess.requestClose<DetailedCloseParams>(placeholderProcessId, {reason: 'completed',savePoint: 'auto_backup_1',timestamp: Date.now(),userInitiated: true});
TYPESCRIPT
Parameters
target
AppProcessId
RequiredThe ID of an app process.
params
T
RequiredParameters to pass to the setOnDispose
callback. Any kind of structured data can be passed via this property.
reason
CloseReason
RequiredThe reason the app process is closing.
Available values:
"completed"
"aborted"
Returns
Promise<void>