Skip to content

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.

Import:

import { getSharedAbortSignal } from 'obsidian-dev-utils/abort-controller';

Example:

await loop({
abortSignal: getSharedAbortSignal(),
buildNoticeMessage: (file) => `Processing ${file.path}`,
items: app.vault.getMarkdownFiles(),
processItem: async (file) => { await processFile(file); }
});

Signature:

function getSharedAbortSignal(): AbortSignal

Returns: AbortSignal — The AbortSignal of the shared ResettableAbortController.

Example:

await loop({
abortSignal: getSharedAbortSignal(),
buildNoticeMessage: (file) => `Processing ${file.path}`,
items: app.vault.getMarkdownFiles(),
processItem: async (file) => { await processFile(file); }
});