Skip to content

Instantly share code, notes, and snippets.

@vincentbello
Created October 12, 2016 05:21
Show Gist options
  • Save vincentbello/84beca1fb93f5cb530fd0c7552894f1f to your computer and use it in GitHub Desktop.
Save vincentbello/84beca1fb93f5cb530fd0c7552894f1f to your computer and use it in GitHub Desktop.
Callback functions -> promises -> generator functions
// 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