Adding extra code to ensure more than one ready timer runs at a time. Exposed IgniteCallback to window.
This commit is contained in:
parent
e36ee1d42c
commit
5a1be0a368
@ -523,20 +523,24 @@ class IgniteRenderingContext {
|
|||||||
IgniteRenderingContext.ReadyCallbacks.push(callback);
|
IgniteRenderingContext.ReadyCallbacks.push(callback);
|
||||||
|
|
||||||
//Clear the existing timer if there is one.
|
//Clear the existing timer if there is one.
|
||||||
if (IgniteRenderingContext.ReadyTimer) {
|
if (IgniteRenderingContext.ReadyTimer && !IgniteRenderingContext.ReadyTimerRunning) {
|
||||||
clearTimeout(IgniteRenderingContext.ReadyTimer);
|
clearTimeout(IgniteRenderingContext.ReadyTimer);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Set a new timeout, it will only run once all elements are ready because
|
//Set a new timeout, it will only run once all elements are ready because
|
||||||
//of the way single threaded timers work.
|
//of the way single threaded timers work.
|
||||||
IgniteRenderingContext.ReadyTimer = setTimeout(async () => {
|
if (!IgniteRenderingContext.ReadyTimerRunning) {
|
||||||
for (var i = 0; i < IgniteRenderingContext.ReadyCallbacks.length; i++) {
|
IgniteRenderingContext.ReadyTimer = setTimeout(async () => {
|
||||||
IgniteRenderingContext.ReadyCallbacks[i].invoke();
|
IgniteRenderingContext.ReadyTimerRunning = true;
|
||||||
}
|
while (IgniteRenderingContext.ReadyCallbacks.length > 0) {
|
||||||
|
await IgniteRenderingContext.ReadyCallbacks.shift().invoke();
|
||||||
|
}
|
||||||
|
|
||||||
IgniteRenderingContext.ReadyCallbacks = [];
|
IgniteRenderingContext.ReadyCallbacks = [];
|
||||||
IgniteRenderingContext.ReadyTimer = null;
|
IgniteRenderingContext.ReadyTimer = null;
|
||||||
}, 1);
|
IgniteRenderingContext.ReadyTimerRunning = false;
|
||||||
|
}, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static get rendering() {
|
static get rendering() {
|
||||||
@ -550,6 +554,7 @@ class IgniteRenderingContext {
|
|||||||
|
|
||||||
window.IgniteRenderingContext = IgniteRenderingContext;
|
window.IgniteRenderingContext = IgniteRenderingContext;
|
||||||
window.IgniteObject = IgniteObject;
|
window.IgniteObject = IgniteObject;
|
||||||
|
window.IgniteCallback = IgniteCallback;
|
||||||
|
|
||||||
export {
|
export {
|
||||||
IgniteProperty,
|
IgniteProperty,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user