actionscript-async

April 28, 2014 ยท View on GitHub

Async utilities for ActionScript, in the style of the async module for Node.js.

Possible alternative to AS3Commons Async.

import com.AndersDJohnson.async.Async;

// ...

Async.tasks( [
  function ( callback:Function):void {
    // ...
    callback( null /* , ... args */ );
  },
  function ( callback:Function):void {
    // ...
    callback( null /* , ... args */ );
  }
  // ...
], function ( error:Error, results:Array ) {
  // results is now an array with results passed to each task function's callback
}

Examples

import com.AndersDJohnson.async.Async;

// ...

Async.tasks( [
  function ( callback:Function):void {
    callback( null, 'one', 1 );
  },
  function ( callback:Function):void {
    callback( null, 'two', 2 );
  }
], function ( error:Error, results:Array ) {
  // results is now equal to [ ['one', 1], ['two', 2] ] 
}