import type { Noop } from '../../utils/noop'; export type Batch = { items: BatchItem[]; cancel: Noop; }; export type BatchItem = { aborted: boolean; key: TKey; resolve: ((value: TValue) => void) | null; reject: ((error: Error) => void) | null; batch: Batch | null; }; export type BatchLoader = { /** * Determines whether the current operation fits in the same batch. */ validate: (keys: TKey[]) => boolean; /** * Queues a request. */ fetch: BatchFetcher; }; export type BatchFetcher = (keys: TKey[], unitResolver: (index: number, value: NonNullable) => void) => { promise: Promise; cancel: Noop; }; export declare class BatchError extends Error { constructor(message?: string); } /** * {@see https://github.com/graphql/dataloader} * * Less configuration, no caching, and allows you to cancel requests. * When cancelling a single fetch the whole batch will be cancelled only when _all_ items are cancelled. */ export declare function batchedDataLoader(loader: BatchLoader): { load: (key: TKey) => { promise: Promise; cancel: () => void; }; }; //# sourceMappingURL=batched-data-loader.d.ts.map