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

API reference for the appProcess.registerOnStateChange method.

Registers a callback that runs when the state of the specified app process changes.

Parameters

targetAppProcessId
REQUIRED

The ID of an app process.

callbackOnStateChangeCallback
REQUIRED

The callback to run when the state of the process changes.

Parameters

optsobject
REQUIRED

Information about the state change.

  • opts.state - The state of the process.
Properties of opts
stateProcessState
REQUIRED

The state of an app process.

The possible states include:

  • "opening" - The app process is opening.
  • "open" - The app process is open, active, and visible on the designated surface.
  • "closing" - The app process is closing.
  • "closed" - The app process has been closed and is no longer active.

While a process is closing, it won't receive any events or messages from other processes.

The available options include:

  • "opening"
  • "open"
  • "closing"
  • "closed"

Returns

void

Returns

A disposer function that cleans up the registered callback.

() => Promise<void>