AbortController utilities.
| Class | Description |
|---|
| ResettableAbortController | An 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. |
| Function | Description |
|---|
| abortSignalAny | An abort signal that aborts when any of the given abort signals abort. |
| abortSignalNever | An abort signal that never aborts. |
| abortSignalTimeout | An abort signal that aborts after a timeout. |
| 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: javascript __obsidianDevUtils.sharedAbortController.value.abort(); |
| getSharedAbortSignal | The 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. |
| onAbort | Adds an abort listener to an abort signal and calls the callback if the abort signal is already aborted. |
| waitForAbort | Waits for an abort signal to abort and resolves with its reason. |