Adding extra code to ensure more than one ready timer runs at a time. Exposed IgniteCallback to window.

This commit is contained in:
MattMo 2022-03-26 02:11:27 -07:00
parent e36ee1d42c
commit 5a1be0a368

View File

@ -523,20 +523,24 @@ class IgniteRenderingContext {
IgniteRenderingContext.ReadyCallbacks.push(callback);
//Clear the existing timer if there is one.
if (IgniteRenderingContext.ReadyTimer) {
if (IgniteRenderingContext.ReadyTimer && !IgniteRenderingContext.ReadyTimerRunning) {
clearTimeout(IgniteRenderingContext.ReadyTimer);
}
//Set a new timeout, it will only run once all elements are ready because
//of the way single threaded timers work.
IgniteRenderingContext.ReadyTimer = setTimeout(async () => {
for (var i = 0; i < IgniteRenderingContext.ReadyCallbacks.length; i++) {
IgniteRenderingContext.ReadyCallbacks[i].invoke();
}
if (!IgniteRenderingContext.ReadyTimerRunning) {
IgniteRenderingContext.ReadyTimer = setTimeout(async () => {
IgniteRenderingContext.ReadyTimerRunning = true;
while (IgniteRenderingContext.ReadyCallbacks.length > 0) {
await IgniteRenderingContext.ReadyCallbacks.shift().invoke();
}
IgniteRenderingContext.ReadyCallbacks = [];
IgniteRenderingContext.ReadyTimer = null;
}, 1);
IgniteRenderingContext.ReadyCallbacks = [];
IgniteRenderingContext.ReadyTimer = null;
IgniteRenderingContext.ReadyTimerRunning = false;
}, 1);
}
}
static get rendering() {
@ -550,6 +554,7 @@ class IgniteRenderingContext {
window.IgniteRenderingContext = IgniteRenderingContext;
window.IgniteObject = IgniteObject;
window.IgniteCallback = IgniteCallback;
export {
IgniteProperty,