39 lines
815 B
TypeScript
39 lines
815 B
TypeScript
// Metro module 5057 (f5058).
|
|
class LazyPromiseInitializer {
|
|
constructor(a0) {
|
|
const r3 = {
|
|
__proto__: new.target.prototype,
|
|
loading: false,
|
|
loaded: false
|
|
};
|
|
r3.loader = a0;
|
|
return r3;
|
|
}
|
|
setParams(a0) {
|
|
if (this.param !== a0) {
|
|
this.param = a0;
|
|
this.loading = false;
|
|
this.loaded = false;
|
|
}
|
|
}
|
|
get() {
|
|
this.ensureLoaded();
|
|
return this.val;
|
|
}
|
|
ensureLoaded() {
|
|
let param;
|
|
if (!this.loaded && !this.loading && this.param !== void 0) {
|
|
param = this.param;
|
|
this.loading = true;
|
|
this.loader(param).then((result) => {
|
|
if (param === this.param) {
|
|
this.val = result;
|
|
this.loading = false;
|
|
this.loaded = true;
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
export default LazyPromiseInitializer;
|