UNPKG

1.28 kBTypeScriptView Raw
1/**
2 * SettlementSignal is used to signal the resolution of a provider/instance.
3 * Calling `complete` or `error` will resolve the promise returned by `asPromise`.
4 * Can be used to detect circular dependencies.
5 */
6export declare class SettlementSignal {
7 private readonly _refs;
8 private readonly settledPromise;
9 private settleFn;
10 private completed;
11 constructor();
12 /**
13 * Resolves the promise returned by `asPromise`.
14 */
15 complete(): void;
16 /**
17 * Rejects the promise returned by `asPromise` with the given error.
18 * @param err Error to reject the promise returned by `asPromise` with.
19 */
20 error(err: unknown): void;
21 /**
22 * Returns a promise that will be resolved when `complete` or `error` is called.
23 * @returns Promise that will be resolved when `complete` or `error` is called.
24 */
25 asPromise(): Promise<unknown>;
26 /**
27 * Inserts a wrapper id that the host of this signal depends on.
28 * @param wrapperId Wrapper id to insert.
29 */
30 insertRef(wrapperId: string): void;
31 /**
32 * Check if relationship is circular.
33 * @param wrapperId Wrapper id to check.
34 * @returns True if relationship is circular, false otherwise.
35 */
36 isCycle(wrapperId: string): boolean;
37}