Created
October 12, 2016 05:21
-
-
Save vincentbello/84beca1fb93f5cb530fd0c7552894f1f to your computer and use it in GitHub Desktop.
Callback functions -> promises -> generator functions
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
// Callback functions | |
function fetchData() { | |
this.fetch('data', (data) => { | |
this.updateUI(); | |
}); | |
} | |
// Promises | |
function fetchData() { | |
this.fetch('data') | |
.then((data) => { | |
this.updateUI(); | |
}); | |
} | |
// Generator functions | |
function * fetchData() { | |
const data = yield this.fetch('data'); | |
this.updateUI(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment