Fixing some bug
This commit is contained in:
@ -28,7 +28,7 @@ export default class AwaitStore<T = any> {
|
||||
|
||||
awaitValue(val: T): PromiseLike<void> & { catch: (cb: (err: any) => PromiseLike<void>) => PromiseLike<void>, ignore: () => void } {
|
||||
|
||||
let ignore: () => void;
|
||||
let ignore: () => void = () => undefined;
|
||||
|
||||
let prms = new Promise<void>(yes => {
|
||||
const cb = () => {
|
||||
@ -41,12 +41,15 @@ export default class AwaitStore<T = any> {
|
||||
return false
|
||||
}
|
||||
|
||||
ignore = () => {
|
||||
this.observable.unsubscribe(cb);
|
||||
}
|
||||
|
||||
if (!cb()) {
|
||||
this.observable.subscribe(cb);
|
||||
if (this._value === val) {
|
||||
yes();
|
||||
} else {
|
||||
ignore = () => {
|
||||
this.observable.unsubscribe(cb);
|
||||
}
|
||||
if (!cb()) {
|
||||
this.observable.subscribe(cb);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user