-
Notifications
You must be signed in to change notification settings - Fork 0
Writing Tasks
pilsy edited this page Mar 6, 2014
·
1 revision
Writing tasks is as easy as:
- Your task must export an uberclass
- Your class when instantiated must accept one argument, “callback” which should be fired when
- Processing has finished and there is no error
- Processing has hit an error before finishing
Below is an example from the “backend-example-module”
ExampleTask from the “backend-example-module”
var Class = require( 'uberclass' )
, async = require( 'async' )
, debug = require( 'debug' )( 'ExampleTask' );
var ExampleTask = module.exports = Class.extend(
{
init: function( callback ) {
debug( ‘Starting…’ );
async.parallel([
this.proxy( ‘doSomething’ ),
this.proxy( ‘doSomethingElse’)
],
function(err, results){
debug( ‘Finished.’ );
callback( err );
});
},
doSomething: function( callback ) {
callback( null );
},
doSomethingElse: function( callback ) {
callback( null );
}
});