DelayedTask Class
A base class for DelayedTask, providing: <ul> <li>Executes the supplied function in the context of the supplied object 'when' milliseconds later</li> </ul>
Quick Example:<br/>
<pre><code>var delayed = new A.DelayedTask({ function() { // This callback will be executed when the <code>DelayedTask</code> be invoked }, scope });
// executes after 1000ms the callback
delayed.delay(1000); </code></pre>
Check the list of <a href="DelayedTask.html#configattributes">Configuration Attributes</a> available for DelayedTask.
Constructor
DelayedTask
-
config
-
fn
-
scope
-
args
Parameters:
-
config
ObjectObject literal specifying widget configuration properties.
-
fn
FunctionCallback
-
scope
ObjectContext object. Optional.
-
args
Object0..n additional arguments that should be provided to the listener.
Methods
_getTime
()
Number
protected
Get the current timestamp (i.e., now).
Returns:
Current timestamp
cancel
()
Cancel the delayed task in case it's running (i.e., clearInterval from the current running <a href="DelayedTask.html#property__id">_id</a>).
delay
-
delay
-
newFn
-
newScope
-
newArgs
<p>This function is responsible to execute the user callback, passed in the <code>constructor</code> after <code>delay</code> milliseconds.</p>
Example:
<pre><code>// executes after 1000ms the callback delayed.delay(1000);</code></pre>
Parameters:
-
delay
NumberDelay in milliseconds.
-
newFn
FunctionCallback.
-
newScope
ObjectContext object. Optional.
-
newArgs
Object0..n additional arguments that should be provided to the listener.
Properties
_args
Object
protected
Stores the passed <code>args</code> attribute.
_fn
Function
protected
Stores the passed <code>fn</code> attribute.
_id
Number
protected
Stores the timer <code>id</code> given from the <code>setInterval</code>.
Default: null
_scope
Object
protected
Stores the passed <code>scope</code> attribute.
Default: instance
_time
Number
protected
Stores the current timestamp given from <a href="DelayedTask.html#method__getTime">_getTime</a>.
Default: 0