export type Comparator = (a: any, b: any) => boolean; /** * A DataLoader is an object that can be used to batch requests for fetching objects from the server for performance * reasons. */ declare abstract class DataLoader { protected readonly fetchBatch: (identifiers: Identifier[]) => Result; private readonly maxBatchSize; private readonly comparator?; protected readonly pendingIdentifiers: Set; constructor(args: { fetchBatch: (identifiers: Identifier[]) => Result; maxBatchSize: number; comparator?: Comparator; }); queue(identifiersToLoad: Identifier[]): void; /** * prepareBatch removes an array of identifiers for data to be loaded from pendingIdentifiers and returns it. If * pendingIdentifiers contains more than maxBatchSize identifiers, then only that many are returned, but if it * contains fewer than that, all of the identifiers are returned and pendingIdentifiers is cleared. */ protected prepareBatch(): { identifiers: Identifier[]; moreToLoad: boolean; }; /** * isBusy is a method for testing which returns true if the DataLoader is waiting to request or receive any data. */ isBusy(): boolean; } /** * A BackgroundDataLoader is an object that can be used to batch requests for fetching objects from the server. Instead * of requesting data immediately, it will periodically check if any objects need to be requested from the server. * * It's intended to be used for loading low priority data such as information needed in response to WebSocket messages * that the user won't see immediately. */ export declare class BackgroundDataLoader extends DataLoader { private intervalId; startIntervalIfNeeded(ms: number): void; stopInterval(): void; fetchBatchNow(): void; isBusy(): boolean; } /** * A DelayedDataLoader is an object that can be used to batch requests for fetching objects from the server. Instead of * requesting data immediately, it will wait for an amount of time and then send a request to the server for all of * the data which would've been requested during that time. * * More specifically, when queue is first called, a timer will be started. Until that timer expires, any other * calls to queue will have the provided identifiers added to the ones from the initial call. When the timer * finally expires, the request will be sent to the server to fetch that data. After that, the timer will be reset and * the next call to queue will start a new one. * * DelayedDataLoader is intended to be used for loading data for components which are unaware of each other and may appear * in different places in the UI from each other which could otherwise send repeated requests for the same or similar * data as one another. */ export declare class DelayedDataLoader extends DataLoader> { private readonly wait; private timeoutId; private timeoutCallbacks; constructor(args: { fetchBatch: (identifiers: Identifier[]) => Promise; maxBatchSize: number; wait: number; comparator?: Comparator; }); queue(identifiersToLoad: Identifier[]): void; queueAndWait(identifiersToLoad: Identifier[]): Promise; private startTimeoutIfNeeded; private resolveCompletedCallbacks; isBusy(): boolean; } export {};