Created
December 16, 2013 13:14
-
-
Save cuipengfei/7986753 to your computer and use it in GitHub Desktop.
promise it wont hurt always async
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 q = require('q'); | |
| var defer = q.defer(); | |
| defer.promise.then(console.log) | |
| defer.resolve("SECOND") | |
| console.log("FIRST") | |
| //despite the promise being resolved synchronously, | |
| //the provided function is not executed until the next turn of the event loop. | |
| //Thus, you should see "FIRST", "SECOND" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment