Last active
August 29, 2015 14:21
-
-
Save caike/61a01b5a97117f16ffc6 to your computer and use it in GitHub Desktop.
Promises demo
This file contains 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("A"); | |
var returnFromTwo = stepOne().then(stepTwo); | |
console.log("B"); | |
returnFromTwo.then(stepThree); | |
console.log("C"); | |
function stepOne(){ | |
console.log("running stepOne"); | |
return new Promise(function(resolve, reject){ | |
console.log("running stepOne Promise"); | |
setTimeout(_ => resolve("resolved stepOne"), 1000); | |
}); | |
} | |
function stepTwo(argToResolve){ | |
console.log("running stepTwo with arg: ", argToResolve); | |
return new Promise(function(resolve, reject){ | |
console.log("running stepTwo Promise"); | |
setTimeout(_ => resolve("resolved stepTwo"), 5000); | |
}); | |
} | |
function stepThree(argToResolve){ | |
console.log("running stepThree ", argToResolve); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output: