Skip to content

getSharedAbortController

The app-wide shared ResettableAbortController.

Every plugin built on this library shares one instance, so a single ResettableAbortController.abort call cancels whatever long-running operation is in flight, whichever plugin started it. A plugin that needs a cancel button of its own scope constructs its own ResettableAbortController instead.

It lives in the shared state, so it is reachable from the devtools console:

globalThis[Symbol.for('@mnaoumov/typescript-lib/state')].values.sharedAbortController.value.abort();

From code, call getSharedAbortController (or getSharedAbortSignal) rather than reading the slot. @mnaoumov/obsidian-lib also mirrors the instance under the legacy __obsidianDevUtils global, but only so that plugins bundling an older obsidian-dev-utils copy share it; new code and new console recipes should not use it.

Import:

import { getSharedAbortController } from '@mnaoumov/typescript-lib/abort-controller';

Signature:

function getSharedAbortController(): ResettableAbortController

Returns: ResettableAbortController — The shared ResettableAbortController.