Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. // 1. Old, sucky way of doing async work: callback hell!
  2. function myCallback(result) {
  3. this.items = result;
  4. }
  5. someAjaxRequest(myCallback);
  6.  
  7.  
  8. // 2. Slightly better way using Promises!
  9. someAjaxRequest().then(results => this.items = results);
  10.  
  11.  
  12. // 3. New awesome sexy way: async/await!
  13. this.items = await someAjaxRequest();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement