Created
July 16, 2014 18:02
-
-
Save heymichaelp/9c04efe01cf3deb0309e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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