/** * Performs a task whenever it becomes dirty. * * Implements debouncing, throttling, race-condition handling, and pause/resume. * * Largely useful to be able to trigger fetches whenever a value changes. * * Use case is perhaps somewhat niche, but I've had to implement similar logic in multiple places, so here it is. * * Used as a helper for `@matchlighter/fetcher`'s `TimedFetch` and in `@inst_proserv/toolkit`'s `DataFetcher` classes. */ export declare class ConcurrentTransactor { private readonly options; constructor(options: { active?: boolean; transact: () => Promise; handleResult: (result: T) => void; debounce?: number | false; max_debounce?: number | false; throttle?: number | false; /** If an older response arrives after a newer request has been issued, should it be ignored? */ filter_stale_results?: boolean; }); private _paused; /** The most recently completed transaction number */ private currentState; /** The most recently queued transaction number */ private wantedState; /** The most recently started transaction number */ private requestedState; get isPaused(): boolean; get isCaughtUp(): boolean; get isExecuting(): boolean; /** Mark the Transactor as dirty and schedule a transaction to be performed */ performSoon(skip_debounce?: boolean): void; /** Mark the Transactor as dirty and perform a transaction immediately */ performNow(): void; /** Immediately perform a transaction if the Transactor is dirty */ performNowIfNeeded(): void; /** Mark the Transactor as clean, cancelling any pending transactions */ markCaughtUp(): void; /** Prevent the Transactor from starting any transactions (started transactions will continue) */ pause(): void; /** Un-pause the Transactor. Will queue a transaction if dirty */ resume(immediate?: boolean): void; private caughtupPromise; private tokenPromises; private resolveTokenPromises; /** * Wait until the Transactor is caught up to any already-triggered triggers. * Has the same effect as `catchupToAll()` if `filter_stale_results: true`. */ catchupToCurrent(): Promise; /** Wait until the Transactor has no pending triggers */ catchupToAll(): Promise; private performTransaction; private _performNow; private _performThrottled; private _performThrottledAndDebounced; }