perform
A sensible deferred library
A current work in progress, so don't use this yet
var log = function( x ) { console.log( x ); };
var dfdA = perform.er();
dfdA.done( log, 'Yay! The deferred resolved!' );
dfdA.fail( log, 'Uh oh, it failed :(' );
var dfdB = perform.er();
dfdB.done( log, 'B is so cool!' );
dfdB.fail( log, 'whatever....' );
perform( log, 'All done bitches' )
.when( dfdA )
.unless( dfdB );
dfdA.resolve();
dfdB.reject();
As for arguments, you can still do a function like normal:
var dfdA = perform.er();
dfdA.done( function( arg1 ) {
console.log( arg1 );
});
dfdA.resolve( 'hi there' );
Or specify stuff inline like this:
var doSomething = function( x, y ) {
console.log( x * y );
};
var dfdA = perform.er();
dfdA.done( doSomething, 5, perform.arg(0) );
dfdA.resolve( 20 );
Getting Started
Install the module with: npm install perform
Documentation
(Coming soon)
Examples
(Coming soon)
Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using grunt.
Release History
(Nothing yet)
License
Copyright (c) 2012 Dan Heberden
Licensed under the MIT license.