Fixing some bug
This commit is contained in:
parent
0781323acb
commit
6720432e24
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hibas123/utils",
|
"name": "@hibas123/utils",
|
||||||
"version": "2.2.0",
|
"version": "2.2.1",
|
||||||
"description": "Different Utilities, that are not worth own packages",
|
"description": "Different Utilities, that are not worth own packages",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"types": "lib/index.d.ts",
|
"types": "lib/index.d.ts",
|
||||||
|
@ -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 } {
|
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 => {
|
let prms = new Promise<void>(yes => {
|
||||||
const cb = () => {
|
const cb = () => {
|
||||||
@ -41,13 +41,16 @@ export default class AwaitStore<T = any> {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this._value === val) {
|
||||||
|
yes();
|
||||||
|
} else {
|
||||||
ignore = () => {
|
ignore = () => {
|
||||||
this.observable.unsubscribe(cb);
|
this.observable.unsubscribe(cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cb()) {
|
if (!cb()) {
|
||||||
this.observable.subscribe(cb);
|
this.observable.subscribe(cb);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
Loading…
Reference in New Issue
Block a user