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.current.requestClose

API reference for the appProcess.current.requestClose method.

Requests the termination of the current process.

Once called, this method:

  1. Transitions the state of the process to "closing".
  2. Invokes all registered setOnDispose callbacks.
  3. Waits for the process to finish closing.
  4. Transitions the state of the process to "closed".

Each time the state changes, all of the registerOnStateChange callbacks are called.

Usage

Close current process

import { appProcess } from '@canva/platform';
await appProcess.current.requestClose({ reason: 'completed' });
TYPESCRIPT

Pass structured data to current process as it closes

import { appProcess, type CloseParams } from '@canva/platform';
type DetailedCloseParams = CloseParams & {
metadata: {
savePoint: string;
timestamp: number;
userInitiated: boolean;
}
};
await appProcess.current.requestClose<DetailedCloseParams>({
reason: 'completed',
metadata: {
savePoint: 'auto_backup_1',
timestamp: Date.now(),
userInitiated: true
}
});
TYPESCRIPT

Parameters

paramsT
Required

Parameters to pass to the setOnDispose callback. Any structured data can be passed via this property.

reasonCloseReason
Required

The reason the app process is closing.

Available values:

  • "completed"
  • "aborted"

Returns

Promise<void>