Show:

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 Object

    Object literal specifying widget configuration properties.

  • fn Function

    Callback

  • scope Object

    Context object. Optional.

  • args Object

    0..n additional arguments that should be provided to the listener.

Index

Methods

_getTime

() Number protected

Get the current timestamp (i.e., now).

Returns:

Number:

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 Number

    Delay in milliseconds.

  • newFn Function

    Callback.

  • newScope Object

    Context object. Optional.

  • newArgs Object

    0..n additional arguments that should be provided to the listener.

Properties

_args

Object protected

Stores the passed <code>args</code> attribute.

_delay

Number protected

Stores the passed <code>delay</code> attribute.

Default: 0

_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