Created
March 12, 2017 18:44
-
-
Save mightyguava/35326d10570dedc3e28882062ed7db72 to your computer and use it in GitHub Desktop.
Demystifying Async Programming in Javascript - fetchJson async generator
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
co(function* () { | |
var user = yield fetchJson('/api/user/self'); | |
var interests = yield fetchJson('/api/user/interests?userId=' + self.id); | |
var recommendations = yield Promise.all( | |
interests.map(i => fetchJson('/api/recommendations?topic=' + i))); | |
render(user, interests, recommendations); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment