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.setOnDispose

API reference for the appProcess.current.setOnDispose method.
This version of the API is in beta. Beta APIs are unstable and may change without warning. You can't release public apps using this API until it's stable.

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

  • Apps can't register multiple callbacks.
  • If an app attempts to register multiple callbacks, only the last callback will be registered.
  • The app process will remain open until the callback resolves or a timeout error occurs.
  • The complete execution of the callback is not guaranteed as some user actions (e.g. closing tabs) may close the process prematurely.

Parameters

callbackOnDisposeCallback<T>
REQUIRED

The callback to run when the current app process is about to close.

Parameters

optsT
REQUIRED

Parameters passed to the setOnDispose callback when a process is about to close.

Properties of opts
reasonCloseReason
REQUIRED

The reason the app process is closing.

The available options include:

  • "completed"
  • "aborted"

Returns

Promise<void>

Returns

A disposer function that cleans up the registered callback.

() => Promise<void>