diff --git a/ignite-html.js b/ignite-html.js index dcb1f7c..deed938 100644 --- a/ignite-html.js +++ b/ignite-html.js @@ -448,9 +448,9 @@ class IgniteCallback { this.detach = detach; } - invoke(...params) { + async invoke(...params) { if (this.callback) { - this.callback(...params); + await this.callback(...params); } } @@ -516,8 +516,11 @@ class IgniteRenderingContext { //Set a new timeout, it will only run once all elements are ready because //of the way single threaded timers work. - IgniteRenderingContext.ReadyTimer = setTimeout(() => { - IgniteRenderingContext.ReadyCallbacks.forEach((ready) => ready.invoke()); + IgniteRenderingContext.ReadyTimer = setTimeout(async () => { + for (var i = 0; i < IgniteRenderingContext.ReadyCallbacks.length; i++) { + IgniteRenderingContext.ReadyCallbacks[i].invoke(); + } + IgniteRenderingContext.ReadyCallbacks = []; IgniteRenderingContext.ReadyTimer = null; }, 1);