Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Javascript Promises

Javascript Promises

Lightning talk about Promises @ SorocabaJs

Felipe Bernardes

May 16, 2016
Tweet

More Decks by Felipe Bernardes

Other Decks in Programming

Transcript

  1. • no more callback hell || pyramid of d00m ◦

    better performance • cleaner && less code ◦ better to undestand ◦ easier to maintain ◦ responsabilities && modularization • better error handling
  2. var p3 = new Promise(function(resolve, reject) { setTimeout(resolve, 100, "three");

    }); var p4 = new Promise(function(resolve, reject) { setTimeout(reject, 500, "four"); }); Promise.race([p3, p4]).then(function(value) { console.log(value); //three }
  3. const setStatus = (group, status) => { const data =

    { status: status, shopId: group.shop.id, }; return $http.post(`${API}/group/${group.id}/shop/status`, data); }; // service
  4. python sorocaba - https://groups.google.com/forum/m/#!forum/python-sorocaba guru sorocaba - https://www.facebook.com/GURUSorocaba/ hacklab -

    https://www.facebook.com/hacklabsorocaba/ GDG Sorocaba - https://www.facebook.com/GDGSorocaba/ SorocabaJS - https://www.facebook.com/sorocabajs/ JS Meetup - http://www.meetup.com/GDG-Sorocaba/ WomenTechmakers - https://www.facebook.com/groups/wtmsorocaba/ in.tegra.do - http://www.meetup.com/In-Tegra-Do/ english meetup - http://www.meetup.com/Sorocaba-English-Conversation-Happy-Hours/ #chegaMais