rvx
Version:
A signal based rendering library
30 lines (29 loc) • 945 B
TypeScript
/**
* A queue for sequentially running async tasks that can be triggered by both the user and side effects.
*/
export declare class Queue {
#private;
/**
* Create a new queue.
*
* When the current lifecycle is disposed, all side effects are aborted and removed from the queue.
*/
constructor();
/**
* Queue a side effect to run if this queue isn't currently blocked.
*
* This will abort and remove all other side effects from the queue.
*
* @param task The side effect to queue.
*/
sideEffect(task: (signal: AbortSignal) => unknown | Promise<unknown>): void;
/**
* Queue a task to run and block this queue until it completes.
*
* This will abort and remove all other side effects from the queue.
*
* @param task The blocking task to queue.
* @returns The result of the task.
*/
block<T>(task: () => T | Promise<T>): Promise<T>;
}