i promise you

41
I Promise you

Upload: william-bruno-moraes

Post on 19-Feb-2017

562 views

Category:

Software


0 download

TRANSCRIPT

I Promise you

William BrunoDesenvolvedor NodeJS

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

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

http://callbackhell.com

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

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

Promises

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

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

Node Pattern

One Ajax

Vanilla

jQuery

AngularJS

BackboneJS

Several Ajax

Callback

Promise

Where do we lost our souls?

Redemption

Reuse

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

One thenable can be reused

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

Obrigado