async load of resources.

@param function function to call on load
191147
public static void whenReady(final EventListener function) {
    JQueryResources.eventLisenerQueue.add(function);
    if (JQueryResources.initializationStarted || JQueryResources.isInHeader()) {
      if (JQueryResources.isInitialized()) {
        JQueryResources.eventLisenerQueue
            .forEach(action -> action.handleEvent(JQueryResources.rememberEvent));
        JQueryResources.eventLisenerQueue.clear();
      }
      return;
    }
    JQueryResources.initializationStarted = true;

    final ScriptElement jqueryScript = Browser.getDocument().createScriptElement();
    jqueryScript.setSrc(JQueryResources.JQUERY_URL);
    jqueryScript.setType(JsResources.SCRIPT_TYPE);

    Browser.getDocument().getHead().appendChild(jqueryScript);

    jqueryScript.setOnload(event -> {
      JQueryResources.eventLisenerQueue.forEach(action -> action.handleEvent(event));
      JQueryResources.eventLisenerQueue.clear();
      JQueryResources.rememberEvent = event;
    });
  }
758600
function load( available, toLoad ) {
    let loadList = available;
    if ('string' === typeof toLoad ) {
      loadList = [toLoad];
    }
    if (Array.isArray(toLoad)) {
      loadList = toLoad;
    }
    loadList.forEach(function( name ) {
      if ( available.indexOf(name) < 0 ) {
        return;
      }
      require('./'+name);
    });
  }
735465
public void addFunction(IFunction function) {
        if ((function != null) && (!functions.contains(function))) {
            functions.add(function);
            colors.add(Color.black);
        }
    }
327287
function whenReady(funcToExecute) {
    if (isReady()) {
        logger.info('Page is already loaded, instantly executing!');
        funcToExecute();
        return;
    }

    logger.info('Waiting for page to be ready');
    callbacksOnReady.push(funcToExecute);
}
269287
function (data) {
            if (!ready) {
                return;
            }
            var i;
            if (data.all === true) {
                data.upto = numPages;
            }
            if (data.page) {
                this.queuePageToLoad(data.page - 1);
            } else if (data.upto) {
                for (i = 0; i < data.upto; ++i) {
                    this.queuePageToLoad(i);
                }
            }
        }
675370
function(tile) {
        tile.onLoadStart = function() {
            this.events.triggerEvent("loadstart");
        };
        tile.events.register("loadstart", this, tile.onLoadStart);
      
        tile.onLoadEnd = function() {
            this.events.triggerEvent("loadend");
        };
        tile.events.register("loadend", this, tile.onLoadEnd);
        tile.events.register("unload", this, tile.onLoadEnd);
    }
1034514
protected void executeWithTransaction(String query, ExecuteFunction function) {
        withTransaction(tx -> execute(tx, query, function));
    }
948478
def asynchronous(function, event):
    
    thread = Thread(target=synchronous, args=(function, event))
    thread.daemon = True
    thread.start()
811263
function( func ) {
				var contents = me._.contents,
					stop = false;

				for ( var i in contents ) {
					for ( var j in contents[ i ] ) {
						stop = func.call( this, contents[ i ][ j ] );
						if ( stop )
							return;
					}
				}
			}
684116
function async (f, args) {
    new Promise(invoke).then(function asyncFulfill () {
      return f.apply(null, args);
    });
  }
472737
function _getCachedFunction(data, vars, relPath) {
  var func;
  if (app.viewCaching) {
      func = app.views.callbacks[relPath];
      if (func instanceof Function) { return func; }
      else { return null; }
  } else { return null; }
}
409471
function(callback) {
    if (typeof callback === 'function') {
      this.afterSync(callback);
    }

    if (this.pendingSync) {
      clearTimeout(this.pendingSync.pop());
      this.pendingSync.forEach(this.cancelQueue);
      this.pendingSync = null;
    }

    if (this.syncing) {
      this.rerun = true;
      return false;
    }

    this.runSync();
    return true;
  }
1013685
public void setFunction(FunctionLibFunction function) {
	function.setFunctionLib(this);
	functions.put(function.getName(), function);
    }
1039743
function onload() {
		// Create pattern
		pattern = ctx.createPattern(img, params.repeat);
		// Run callback function if defined
		if (params.load) {
			params.load.call($canvases[0], pattern);
		}
	}
488140
function(func, wait) {
        var self = this,
            timeout,
            // args, // right now there is no need for arguments
            // context, // and for context
            timestamp
            // result // and for result

        var later = function() {
            if (self._disposed) {
                clearTimeout(timeout)
                timeout = self = null
                return
            }

            var last = getTime() - timestamp

            if (last < wait && last >= 0) {
                timeout = setTimeout(later, wait - last)
            } else {
                timeout = null
                // result = func.apply(context, args)
                func()
                // context = args = null
            }
        }

        return function() {
            // context = this
            // args = arguments
            timestamp = getTime()

            if (!timeout) {
                timeout = setTimeout(later, wait)
            }

            // return result
        }
    }
752869
function load (url, callback, sendCallbackWhenAlreadyLoaded) {
        if (sendCallbackWhenAlreadyLoaded == undefined) {
            sendCallbackWhenAlreadyLoaded = true;
        }

        if (isLoaded(url)) {
            if (sendCallbackWhenAlreadyLoaded) {
                callback(url);
            }
            return;
        }

        if (isLoading(url) && !sendCallbackWhenAlreadyLoaded) {
            return;
        }

        var c = callbacks[url];
        if (!c) {
            var image = new Image();
            image.src = url;

            c = [];
            callbacks[url] = c;

            image.onload = function (event) {
                urls[url] = true;
                delete callbacks[url];

                for (var i = 0; i < c.length; i++) {
                    c[i](url);
                }
            }
        }

        if (c.indexOf(callback) == -1) {
            c.push(callback);
        }
    }
971839
function toSource(func) {
  if (func != null) {
    try {
      return funcToString$1.call(func);
    } catch (e) {}
    try {
      return (func + '');
    } catch (e) {}
  }
  return '';
}