Fixed circular reference #2
This commit is contained in:
2
out/helpers/resolvable.d.ts
vendored
2
out/helpers/resolvable.d.ts
vendored
@@ -11,6 +11,7 @@ declare class FetchOnce<T, U extends Array<unknown>> {
|
||||
protected state: ResolvableState;
|
||||
protected pendings: [(res: Promise<T> | T) => void, (reason: unknown) => void][];
|
||||
constructor(fetchMethod?: ((...args: U) => Promise<T>) | undefined);
|
||||
reset(): void;
|
||||
resolve(...args: U): Promise<T>;
|
||||
protected isFinished(): boolean;
|
||||
protected parsePromise(promise: Promise<T>): void;
|
||||
@@ -23,5 +24,6 @@ export declare class WaitForSync<T> extends FetchOnce<T, never> {
|
||||
constructor();
|
||||
setData(data: T): void;
|
||||
setError(error: unknown): void;
|
||||
reset(): void;
|
||||
}
|
||||
export {};
|
||||
|
||||
@@ -23,8 +23,12 @@ class FetchOnce {
|
||||
this.state = ResolvableState.WAITING;
|
||||
this.pendings = [];
|
||||
}
|
||||
reset() {
|
||||
this.data = undefined;
|
||||
this.error = undefined;
|
||||
this.state = ResolvableState.WAITING;
|
||||
}
|
||||
resolve(...args) {
|
||||
// eslint-disable-next-line promise/avoid-new
|
||||
return new Promise((resolve, reject) => {
|
||||
switch (this.state) {
|
||||
case ResolvableState.WAITING:
|
||||
@@ -81,5 +85,9 @@ class WaitForSync extends FetchOnce {
|
||||
this.parsePromise((() => __awaiter(this, void 0, void 0, function* () { throw error; }))());
|
||||
}
|
||||
}
|
||||
reset() {
|
||||
super.reset();
|
||||
this.state = ResolvableState.PENDING;
|
||||
}
|
||||
}
|
||||
exports.WaitForSync = WaitForSync;
|
||||
|
||||
Reference in New Issue
Block a user