UNPKG

@nitrogenbuilder/client-core

Version:

Nitrogen Builder Core Client

29 lines 952 B
export type BatchRequest = { key: string; endpoint: string; params: Record<string, string>; }; export type BatchResult = { data: any; total: number; totalPages: number; }; export type BatchTransport = (requests: BatchRequest[]) => Promise<Record<string, BatchResult>>; export declare class BatchFetchContext { private transport; private requests; private pendingResolvers; private flushed; constructor(transport: BatchTransport); /** * Called by getData functions to register a request. * Returns a promise that resolves after flush() completes. */ fetch(endpoint: string, params?: Record<string, string>): Promise<BatchResult>; /** * Called after all getData functions have registered their requests. * Sends a single batch request via the transport and resolves all pending promises. */ flush(): Promise<void>; } //# sourceMappingURL=BatchFetchContext.d.ts.map