feat(lazy): created to handle lazy loading
This commit is contained in:
@@ -50,6 +50,7 @@
|
|||||||
<script src="~/lib/bootstrap/dist/js/bootstrap.min.js"></script>
|
<script src="~/lib/bootstrap/dist/js/bootstrap.min.js"></script>
|
||||||
<script src="~/lib/sweetalert2/sweetalert2.min.js"></script>
|
<script src="~/lib/sweetalert2/sweetalert2.min.js"></script>
|
||||||
<script src="~/lib/alertifyjs/alertify.min.js"></script>
|
<script src="~/lib/alertifyjs/alertify.min.js"></script>
|
||||||
|
<script src="~/js/lazy.min.js" asp-append-version="true"></script>
|
||||||
<script src="~/js/ui.min.js" asp-append-version="true"></script>
|
<script src="~/js/ui.min.js" asp-append-version="true"></script>
|
||||||
<script src="~/js/annotation.js" asp-append-version="true"></script>
|
<script src="~/js/annotation.js" asp-append-version="true"></script>
|
||||||
<script src="~/js/network.min.js" asp-append-version="true"></script>
|
<script src="~/js/network.min.js" asp-append-version="true"></script>
|
||||||
|
|||||||
@@ -5,6 +5,12 @@
|
|||||||
"wwwroot/js/app.js"
|
"wwwroot/js/app.js"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"outputFileName": "wwwroot/js/lazy.min.js",
|
||||||
|
"inputFiles": [
|
||||||
|
"wwwroot/js/lazy.js"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"outputFileName": "wwwroot/js/api-service.min.js",
|
"outputFileName": "wwwroot/js/api-service.min.js",
|
||||||
"inputFiles": [
|
"inputFiles": [
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ const url = {
|
|||||||
|
|
||||||
get envKey() {
|
get envKey() {
|
||||||
if (!this.__envKey) {
|
if (!this.__envKey) {
|
||||||
this.__envKey =
|
this.__envKey =
|
||||||
typeof envKey !== "undefined"
|
typeof envKey !== "undefined"
|
||||||
? envKey
|
? envKey
|
||||||
: document.querySelector('meta[name="env-key"]').getAttribute('content');
|
: 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