Skip to content

Instantly share code, notes, and snippets.

@JudahGabriel
Created April 24, 2017 21:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JudahGabriel/3ed5e4203f28bb0e4f6df1efe2bc13ac to your computer and use it in GitHub Desktop.
Save JudahGabriel/3ed5e4203f28bb0e4f6df1efe2bc13ac to your computer and use it in GitHub Desktop.
// 1. Old, sucky way of doing async work: callback hell!
function myCallback(result) {
this.items = result;
}
someAjaxRequest(myCallback);
// 2. Slightly better way using Promises!
someAjaxRequest().then(results => this.items = results);
// 3. New awesome sexy way: async/await!
this.items = await someAjaxRequest();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment