UNPKG

1.94 kBTypeScriptView Raw
1import { IFetchOptions } from "@pnp/common";
2import { IODataParser } from "./parsers.js";
3import { IQueryable } from "./queryable.js";
4import { IRequestContext } from "./pipeline.js";
5export interface IODataBatchRequestInfo {
6 url: string;
7 method: string;
8 options: IFetchOptions;
9 parser: IODataParser<any>;
10 resolve: ((d: any) => void) | null;
11 reject: ((error: any) => void) | null;
12 id: string;
13 index: number;
14}
15export declare abstract class Batch {
16 private _batchId;
17 protected _deps: Promise<void>[];
18 protected _reqs: IODataBatchRequestInfo[];
19 protected _rDeps: Promise<void>[];
20 private _index;
21 constructor(_batchId?: string);
22 get batchId(): string;
23 /**
24 * The requests contained in this batch
25 */
26 protected get requests(): IODataBatchRequestInfo[];
27 /**
28 * Not meant for use directly
29 *
30 * @param batchee The IQueryable for this batch to track in order
31 */
32 track(batchee: IQueryable<any>): void;
33 /**
34 * Adds the given request context to the batch for execution
35 *
36 * @param context Details of the request to batch
37 */
38 add<T = any>(context: IRequestContext<T>): Promise<T>;
39 /**
40 * Adds a dependency insuring that some set of actions will occur before a batch is processed.
41 * MUST be cleared using the returned resolve delegate to allow batches to run
42 */
43 addDependency(): () => void;
44 /**
45 * The batch's execute method will not resolve util any promises added here resolve
46 *
47 * @param p The dependent promise
48 */
49 addResolveBatchDependency(p: Promise<any>): void;
50 /**
51 * Execute the current batch and resolve the associated promises
52 *
53 * @returns A promise which will be resolved once all of the batch's child promises have resolved
54 */
55 execute(): Promise<void>;
56 protected abstract executeImpl(): Promise<void>;
57}
58//# sourceMappingURL=batch.d.ts.map
\No newline at end of file