ExitCallback
@totemsdk/pear / ExitCallback
Type Alias: ExitCallback
ExitCallback = () =>
void|Promise<void>
@totemsdk/pear — App lifecycle
createPearApp registers teardown handlers with the Pear runtime (when
present). onExit queues cleanup callbacks invoked in LIFO order on shutdown.
In non-Pear environments (Node.js, Bare without Pear), callers can trigger
shutdown manually via runExitHandlers().
Bare-compatible: no process.env, no __dirname, no require.
Guards against globalThis.Pear being absent (tests, Node.js CI).
Registration semantics:
teardowncallback (runExitHandlers) is registered once withPear.teardown— Pear only supports a single teardown hook, so multiplecreatePearAppcalls do not double-register it.onUpdatecallbacks are registered every timecreatePearAppis called with a non-nullonUpdate— callers may legitimately update the handler between Pear hot-reloads and registering again is safe.
Returns
void | Promise<void>