obsidian-dev-utils
Version:
This is the collection of useful functions that you can use for your Obsidian plugin development
92 lines (91 loc) • 2.31 kB
text/typescript
/**
* @packageDocumentation
*
* Contains utility functions for enqueuing and processing functions in Obsidian.
*/
import type { App } from 'obsidian';
import type { Promisable } from 'type-fest';
/**
* Options for the {@link addToQueueAndWait} function.
*/
export interface AddToQueueAndWaitOptions {
/**
* Optional abort signal.
*/
abortSignal?: AbortSignal;
/**
* The Obsidian application instance.
*/
app: App;
/**
* The function to add.
*/
operationFn: (abortSignal: AbortSignal) => Promisable<void>;
/**
* Optional name of the operation.
*/
operationName?: string;
/**
* Whether to show a timeout notice. Default is `true`.
*/
shouldShowTimeoutNotice?: boolean;
/**
* Optional stack trace.
*/
stackTrace?: string;
/**
* The timeout in milliseconds.
*/
timeoutInMilliseconds?: number;
}
/**
* Options for the {@link addToQueue} function.
*/
export interface AddToQueueOptions {
/**
* Optional abort signal.
*/
abortSignal?: AbortSignal;
/**
* The Obsidian application instance.
*/
app: App;
/**
* The function to add.
*/
operationFn: (abortSignal: AbortSignal) => Promisable<void>;
/**
* Optional name of the operation.
*/
operationName?: string;
/**
* Whether to show a timeout notice. Default is `true`.
*/
shouldShowTimeoutNotice?: boolean;
/**
* Optional stack trace.
*/
stackTrace?: string;
/**
* The timeout in milliseconds.
*/
timeoutInMilliseconds?: number;
}
/**
* Adds an asynchronous function to be executed after the previous function completes.
*
* @param options - The options for the function.
*/
export declare function addToQueue(options: AddToQueueOptions): void;
/**
* Adds an asynchronous function to be executed after the previous function completes and returns a {@link Promise} that resolves when the function completes.
*
* @param options - The options for the function.
*/
export declare function addToQueueAndWait(options: AddToQueueAndWaitOptions): Promise<void>;
/**
* Flushes the queue;
*
* @param app - The Obsidian application instance.
*/
export declare function flushQueue(app: App): Promise<void>;