Skip to content

Instantly share code, notes, and snippets.

@heymichaelp
Created July 16, 2014 18:02
Show Gist options
  • Save heymichaelp/9c04efe01cf3deb0309e to your computer and use it in GitHub Desktop.
Save heymichaelp/9c04efe01cf3deb0309e to your computer and use it in GitHub Desktop.
var Service = require('./service');
var CreateAccount = Service.extend({
procedure: [
'persist',
'sendEmail',
'generateSomething'
],
// defining resolve and reject arguments
// wraps the function in a promise that you can
// resolve (success) or reject (error);
persist: function( resolve, reject ) {
SomeSaveToDatabaseFunction();
resolve();
},
sendEmail: function() {
return emailSentTimestamp;
},
generateSomething: function( emailSentTimestamp ) {
return somethingElse;
}
});
new CreateAccount({firstName: 'Michael', lastName: 'Phillips'}).run()
.then(successHandler)
.fail(errorHandler);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment