Skip to content

abort-controller

AbortController utilities.

ClassDescription
ResettableAbortControllerAn AbortController that can be aborted more than once. A plain AbortController is single-use: once aborted, its signal stays aborted forever, so it cannot back a cancel button that the user may press more than once. This one aborts the current signal and immediately replaces it, so the next operation starts with a fresh, non-aborted signal while the work that captured the previous signal still observes the abort. Read ResettableAbortController.signal at the start of each operation. Never cache it, or the operation after the first abort starts already aborted.
FunctionDescription
abortSignalAnyAn abort signal that aborts when any of the given abort signals abort.
abortSignalNeverAn abort signal that never aborts.
abortSignalTimeoutAn abort signal that aborts after a timeout.
getSharedAbortControllerThe 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: javascript __obsidianDevUtils.sharedAbortController.value.abort();
getSharedAbortSignalThe signal of the app-wide shared ResettableAbortController. Call it at the start of each operation. Never cache it, or the operation after the first abort starts already aborted.
onAbortAdds an abort listener to an abort signal and calls the callback if the abort signal is already aborted.
waitForAbortWaits for an abort signal to abort and resolves with its reason.
VariableDescription
INFINITE_TIMEOUTA constant representing an infinite timeout.