diff --git a/helpers/LazyVal.ts b/helpers/LazyVal.ts index 0217647ba57f2fd0399d85632e6106833975b438..ee0d8d464b0e99ea790ac9326868c3275745c226 100644 --- a/helpers/LazyVal.ts +++ b/helpers/LazyVal.ts @@ -1,11 +1,11 @@ class LazyVal<T> { - private val: T = null; + private val: T | undefined = undefined; constructor(private valLoader: () => Promise<T> | T) {} get value(): Promise<T> { return new Promise<T>(async (resolve) => { - if ( this.val === null ) { + if ( this.val === undefined ) { this.val = await this.valLoader(); } @@ -14,11 +14,11 @@ class LazyVal<T> { } reset() { - this.val = null; + this.val = undefined; } get isValueLoaded(): boolean { - return this.val !== null; + return this.val !== undefined; } }