Debian Codegraph @

dojox/timing/doLater.js

raw symbols SCIP
1 define(["./_base"], function(dxt){
2 dojo.experimental("dojox.timing.doLater");
3
4 dxt.doLater = function(/*anything*/conditional,/*Object ?*/context, /* Number ? */interval){
5 // summary:
6 // Check if a parameter is ready, and if not,
7 // "do later". doLater will ping the parameter
8 // until it evaluates to something (truthy).
9 // It thens calls the caller with original
10 // arguments, using the supplied context or
11 // window.
12 // description:
13 // dojox.timing.doLater(conditional) is testing if the call
14 // should be done later. So it returns
15 // true if the param is false.
16 // conditional: anything
17 // Can be a property that eventually gets set, or
18 // an expression, method... anything that can be
19 // evaluated.
20 // context: Object
21 // The namespace where the call originated.
22 // Defaults to global and anonymous functions
23 // interval: Number
24 // Poll time to check conditional in Milliseconds
25 // example:
26 // | setTimeout(function(){
27 // | if(dojox.timing.doLater(app.ready)){return;}
28 // | console.log("Code is ready! anonymous.function SUCCESS")
29 // | },700);
30
31 if(conditional){ return false; } // Boolean
32 var callback = dxt.doLater.caller,
33 args = dxt.doLater.caller.arguments;
34 interval = interval || 100;
35 context = context || dojo.global;
36
37 setTimeout(function(){
38 callback.apply(context, args);
39 },interval);
40 return true; // Boolean
41 };
42 return dxt.doLater;
43 });