Top Banner
I Promise you
41

I Promise You

Feb 19, 2017

Download

Software

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: I Promise You

I Promise you

Page 2: I Promise You

William BrunoDesenvolvedor NodeJS

http://wbruno.com.br/ http://github.com/wbruno [email protected] @wbrunom

Page 3: I Promise You

- Eu trabalho com JavaScript! - Ahh, callback hell ne?!

http://callbackhell.com

Page 4: I Promise You
Page 5: I Promise You

CallbackIt’s a function, that will be called when something is done.

Page 6: I Promise You
Page 7: I Promise You

Callback problems• Don’t have return • Don’t have throw • Nesting • No guarantees (flow, parallel)

Page 8: I Promise You

Promises

Page 9: I Promise You
Page 10: I Promise You

PromiseIt’s a object, then some time in future will be full filed, or not.

Page 11: I Promise You
Page 12: I Promise You
Page 13: I Promise You

Libs• https://github.com/kriskowal/q • https://github.com/cujojs/when • https://github.com/petkaantonov/bluebird

http://programmers.stackexchange.com/questions/278778/why-are-native-es6-promises-slower-and-more-memory-intensive-than-bluebird

Page 14: I Promise You

Node Pattern

Page 15: I Promise You

One Ajax

Page 16: I Promise You
Page 17: I Promise You
Page 18: I Promise You

Vanilla

Page 19: I Promise You
Page 20: I Promise You

jQuery

Page 21: I Promise You

AngularJS

Page 22: I Promise You

BackboneJS

Page 23: I Promise You

Several Ajax

Page 24: I Promise You
Page 25: I Promise You
Page 26: I Promise You

Callback

Page 27: I Promise You
Page 28: I Promise You
Page 29: I Promise You

Promise

Page 30: I Promise You
Page 31: I Promise You
Page 32: I Promise You

Where do we lost our souls?

Page 33: I Promise You
Page 34: I Promise You

Redemption

Page 35: I Promise You
Page 36: I Promise You
Page 37: I Promise You

Reuse

Page 38: I Promise You

A promise can return other promise A promise can return sync values

One thenable can be reused

Page 39: I Promise You

Bibliografia

https://promisesaplus.com http://pouchdb.com/2015/05/18/we-have-a-problem-with-promises.html https://www.youtube.com/watch?v=hf1T_AONQJU https://www.youtube.com/watch?v=6hGvX4e69LI https://gist.github.com/domenic/3889970

https://github.com/wbruno/examples/tree/gh-pages/i-promise-you

Page 40: I Promise You

Obrigado

Page 41: I Promise You