partial.js logo
Latest version
v1.3.1 (RC2)

Async


Async class is helpful for asynchronous work. Is defined in FrameworkUtils (utils.js). FrameworkUtils is a global variable.


Example:


var async = new utils.Async();

async.await(function(next) {
	next();
};

Properties


async.count {int}async.percentage {Number}
async.count;Default: 0
readonly
return int;

How many tasks are waiting?

async.percentage;Default: 0
readonly
return Number;

Working percentage.

Methods


async.await([name], fn, [cb])async.cancel()async.cancel([name])async.complete([callback])async.isPending(name)async.isRunning([name])async.isWaiting(name)async.run([callback])async.timeout(name, [timeout])async.wait(name, [waitingFor], fn, [cb])
async.await([name], fn, [cb]);
return Async;

Add a function to async list.

async.cancel();
return Async;

Cancel work.

async.cancel([name]);
return Async;

Cancel specific task or cancel all tasks.

async.complete([callback]);
return Async;

Run async functions.

async.isPending(name);
return Boolean;

Check if task is in async task collection.

async.isRunning([name]);
return Boolean;

Is running specific task or is running are tasks?

async.isWaiting(name);
return Boolean;

Check if task is waiting for execute.

async.run([callback]);
return Async;

Run async functions.

async.timeout(name, [timeout]);
return Async;

Set timeout for specific task. This function sets timeout into the future and for current (waiting/pending/running) task. You can disabled timeout: async.timeout('name'); or async.timeout('name', 0).

async.wait(name, [waitingFor], fn, [cb]);
return Async;

Add a function to async waiting list.