Fixing some bug

This commit is contained in:
Fabian Stamm 2019-11-26 22:06:27 +01:00
parent 0781323acb
commit 6720432e24
2 changed files with 11 additions and 8 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@hibas123/utils",
"version": "2.2.0",
"version": "2.2.1",
"description": "Different Utilities, that are not worth own packages",
"main": "lib/index.js",
"types": "lib/index.d.ts",

View File

@ -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);
}
}
});