Created
April 14, 2016 13:13
-
-
Save dksheffield/525a1a89c3b507bb53d036be9476f186 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
console.log('Loading function'); | |
var Promise = require('promise'); | |
doPromiseOne() | |
.then(doPromiseTwo) | |
.then(doPromiseThree); | |
function doPromiseOne() { | |
return promiseOne().then(function(data) { | |
console.log(data); | |
}); | |
} | |
function doPromiseTwo() { | |
return promiseTwo().then(function(data) { | |
console.log(data); | |
}); | |
} | |
function doPromiseThree() { | |
return promiseThree().then(function(data) { | |
console.log(data); | |
}); | |
} | |
function failPromise(msg) { | |
throw new Error(msg); | |
} | |
function promiseOne() { | |
console.log("starting promise one"); | |
return new Promise(function (fulfill, reject){ | |
setTimeout(function () { | |
console.log("promise one success"); | |
fulfill("promise one success"); | |
}, 2000) | |
}); | |
} | |
function promiseTwo() { | |
console.log("starting promise two"); | |
return new Promise(function (fulfill, reject){ | |
setTimeout(function () { | |
console.log("promise two success"); | |
fulfill("promise two success"); | |
}, 2000) | |
}); | |
} | |
function promiseThree() { | |
console.log("starting promise three"); | |
return new Promise(function (fulfill, reject){ | |
setTimeout(function () { | |
console.log("promise three success"); | |
fulfill("promise three success"); | |
}, 2000) | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment