javascript - while vs setInterval -
The following are the following arrays to monitor widgets initiated by the app I'm working on: < / Selector: ".otherother", init: function () {...} }]
Each init function is using a plugin This selector is called "readyWidgets" (for example ".table") push another array for a plugin its functions On completion,
The question now is:
Can I tell in one go all the nested nested under the primary widgets array are present in the Witts array?
I'm going to have a blackout, though I have a solution, I think I'm missing a better one.
This is what came with me:
init: function () {// it will keep each widget selector and see it in the readywidth array later in the widgetsPending = [] // widgets array // (only if the selector matches at least one element) start this widget in each widget ($ widget.selector) in this.widgets.forEach (function (widget) .length & amp; ; WidgetsPending.Pink (widget.selector) & amp; Widget.init ()}, this // // function in the functioning pandings array is present in this value interval = if this value is // this.readyWidgets Let's go To use = setInterval setInterval () {// just make sure that the interval is approved to create console.log (that.readyWidgets) // if a value in widgetsPending is not in // that.readyWidgets If found, pageReady will be marked false on pageReady = true widgetsPending.forEach (function (selector) {if (that.readyWidgets.indexOf (selector) == -1) {pageReady = false}}) // if widgetsReady is true, Interval pageReady & amp; & Amp; ClearInterval (difference text "itemprop =" text "> something like this: < / P>
var load operation = []; objects.forEach (function (obj) {var loadComplete = $ .Deferred (); loadOperations.push (loadComplete); // long running async function call this function Postponement or obj.someLongRunningEGLoadOperation promise can return (function () {// async function full callback loadComplete.resolve ();});}); $ .apple ($, load operation) .one (function ( ) {// do something, then all long lasting tasks are completed});
Comments
Post a Comment