feat(lazy): created to handle lazy loading
This commit is contained in:
@@ -20,7 +20,7 @@ const url = {
|
||||
|
||||
get envKey() {
|
||||
if (!this.__envKey) {
|
||||
this.__envKey =
|
||||
this.__envKey =
|
||||
typeof envKey !== "undefined"
|
||||
? envKey
|
||||
: document.querySelector('meta[name="env-key"]').getAttribute('content');
|
||||
|
||||
22
EnvelopeGenerator.Web/wwwroot/js/lazy.js
Normal file
22
EnvelopeGenerator.Web/wwwroot/js/lazy.js
Normal file
@@ -0,0 +1,22 @@
|
||||
class Lazy {
|
||||
#factory;
|
||||
#initialized = false;
|
||||
#value;
|
||||
|
||||
constructor(factory) {
|
||||
this.#factory = factory;
|
||||
}
|
||||
|
||||
get initialized() {
|
||||
return this.#initialized;
|
||||
}
|
||||
|
||||
get value() {
|
||||
if (!this.#initialized) {
|
||||
this.#initialized = true;
|
||||
this.#value = this.#factory();
|
||||
this.#factory = null;
|
||||
}
|
||||
return this.#value;
|
||||
}
|
||||
}
|
||||
1
EnvelopeGenerator.Web/wwwroot/js/lazy.min.js
vendored
Normal file
1
EnvelopeGenerator.Web/wwwroot/js/lazy.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
class Lazy{#factory;#initialized=false;#value;constructor(n){this.#factory=n}get initialized(){return this.#initialized}get value(){return this.#initialized||(this.#initialized=!0,this.#value=this.#factory(),this.#factory=null),this.#value}}
|
||||
Reference in New Issue
Block a user