Fixed a bug with IgniteProperty toString. Added more documentation. Ready callbacks now support regular functions or callbacks.
This commit is contained in:
parent
73bf9812dd
commit
118e4367df
@ -356,7 +356,11 @@ class IgniteProperty {
|
||||
* the property to a string.
|
||||
*/
|
||||
IgniteProperty.prototype.toString = function () {
|
||||
return this.value.toString();
|
||||
if (this.value) {
|
||||
return this.value.toString();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -485,12 +489,19 @@ class IgniteCallback {
|
||||
this.detach = detach;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes this callback.
|
||||
* @param {...any} params Any params to pass to the target function.
|
||||
*/
|
||||
async invoke(...params) {
|
||||
if (this.callback) {
|
||||
await this.callback(...params);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes the detach callback for this callback if there is one.
|
||||
*/
|
||||
disconnect() {
|
||||
this.callback = null;
|
||||
|
||||
@ -508,6 +519,9 @@ class IgniteCallback {
|
||||
* @ignore
|
||||
*/
|
||||
class IgniteRendering {
|
||||
/**
|
||||
* Increments the rendering counter. Must call leave() for each enter().
|
||||
*/
|
||||
static enter() {
|
||||
if (!IgniteRendering.RenderCount) {
|
||||
IgniteRendering.RenderCount = 0;
|
||||
@ -516,12 +530,18 @@ class IgniteRendering {
|
||||
IgniteRendering.RenderCount++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrements the rendering counter, if 0, rendering() will return false.
|
||||
*/
|
||||
static leave() {
|
||||
if (IgniteRendering.RenderCount) {
|
||||
IgniteRendering.RenderCount--;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the current rendering state.
|
||||
*/
|
||||
static push() {
|
||||
if (IgniteRendering.Stack == null) {
|
||||
IgniteRendering.Stack = [];
|
||||
@ -531,12 +551,19 @@ class IgniteRendering {
|
||||
IgniteRendering.RenderCount = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restores the last rendering state.
|
||||
*/
|
||||
static pop() {
|
||||
if (IgniteRendering.Stack && IgniteRendering.Stack.length > 0) {
|
||||
IgniteRendering.RenderCount = IgniteRendering.Stack.pop();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a callback function that will be invoked once rendering is complete.
|
||||
* @param {IgniteCallback|Function} callback The callback function to invoke once rendering is complete.
|
||||
*/
|
||||
static ready(callback) {
|
||||
//Setup the callbacks if it's not init'd.
|
||||
if (!IgniteRendering.ReadyCallbacks) {
|
||||
@ -557,7 +584,13 @@ class IgniteRendering {
|
||||
IgniteRendering.ReadyTimer = setTimeout(async () => {
|
||||
IgniteRendering.ReadyTimerRunning = true;
|
||||
while (IgniteRendering.ReadyCallbacks.length > 0) {
|
||||
IgniteRendering.ReadyCallbacks.shift().invoke();
|
||||
var callback = IgniteRendering.ReadyCallbacks.shift();
|
||||
|
||||
if (callback instanceof IgniteCallback) {
|
||||
callback.invoke();
|
||||
} else if (callback instanceof Function) {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
|
||||
IgniteRendering.ReadyCallbacks = [];
|
||||
@ -567,12 +600,11 @@ class IgniteRendering {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not we are currently in a rendering state.
|
||||
*/
|
||||
static get rendering() {
|
||||
if (IgniteRendering.RenderCount && IgniteRendering.RenderCount > 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return IgniteRendering.RenderCount && IgniteRendering.RenderCount > 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user