Alloy UI

aui-delayed-task  1.0.1

 
Filters

Class DelayedTask

A base class for DelayedTask, providing:
  • Executes the supplied function in the context of the supplied object 'when' milliseconds later
Quick Example:
var delayed = new A.DelayedTask({
function() {
// This callback will be executed when the DelayedTask be invoked
},
scope
});
// executes after 1000ms the callback
delayed.delay(1000);
Check the list of Configuration Attributes 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.

Properties

_args - protected Object

Stores the passed args attribute.

_delay - protected Number

Stores the passed delay attribute.
Default Value: 0

_fn - protected function

Stores the passed fn attribute.

_id - protected Number

Stores the timer id given from the setInterval.
Default Value: null

_scope - protected Object

Stores the passed scope attribute.
Default Value: instance

_time - protected Number

Stores the current timestamp given from _getTime.
Default Value: 0

Methods

_getTime

protected Number _getTime ( )
Get the current timestamp (i.e., now).
Returns: Number
Current timestamp

cancel

void cancel ( )
Cancel the delayed task in case it's running (i.e., clearInterval from the current running _id).

delay

void delay ( delay , newFn , newScope , newArgs )

This function is responsible to execute the user callback, passed in the constructor after delay milliseconds.

Example:
// executes after 1000ms the callback
delayed.delay(1000);
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.