Skip to content
Snippets Groups Projects
Commit da42b3d4 authored by michael.minelli's avatar michael.minelli
Browse files

LazyVal => Bug fix : missing possibly undefined type

parent 69b93951
No related branches found
No related tags found
No related merge requests found
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;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment