Added reset to resolvable.ts
This commit is contained in:
@@ -13,8 +13,13 @@ class FetchOnce<T, U extends Array<unknown>> {
|
||||
|
||||
constructor(protected fetchMethod?: (...args: U) => Promise<T>) { }
|
||||
|
||||
public reset(): void {
|
||||
this.data = undefined;
|
||||
this.error = undefined;
|
||||
this.state = ResolvableState.WAITING;
|
||||
}
|
||||
|
||||
public resolve(...args: U): Promise<T> {
|
||||
// eslint-disable-next-line promise/avoid-new
|
||||
return new Promise((resolve, reject) => {
|
||||
switch (this.state) {
|
||||
case ResolvableState.WAITING:
|
||||
@@ -76,4 +81,9 @@ export class WaitForSync<T> extends FetchOnce<T, never> {
|
||||
this.parsePromise((async () => { throw error; })());
|
||||
}
|
||||
}
|
||||
|
||||
public reset(): void {
|
||||
super.reset();
|
||||
this.state = ResolvableState.PENDING;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user