$30 off During Our Annual Pro Sale. View Details »

Combining Generators with Promises and Channels

Combining Generators with Promises and Channels

JavaScript Weekly Lightning Talks
Wednesday 23 Oct 2013 from 6:00pm - 9:00pm
http://www.sydjs.com/meetups/javascript-weekly-lightning-talks

“Don't combine Generators with Promises, combine them with Channels!” – David Nolen

Filippo Vitale

October 23, 2013
Tweet

More Decks by Filippo Vitale

Other Decks in Programming

Transcript

  1. Combining Generators with Promises and Channels “Don't combine Generators with

    Promises, combine them with Channels!” David Nolen
  2. Everyday’s jQuery

  3. JQuery AJAX Innocent function

  4. JQuery AJAX Innocent function

  5. JQuery AJAX Sync or Async?

  6. JQuery AJAX Sync or Async? SJAX

  7. JQuery AJAX Sync or Async?

  8. JQuery AJAX Sync or Async?

  9. Parallelism Concurrency

  10. Parallelism in one GIF

  11. Parallelism in one GIF http://goo.gl/0lmTG6

  12. Parallelism in one GIF “Parallelism is about doing lots of

    things at once” -- Rob Pike
  13. Concurrency in one GIF

  14. Concurrency in one GIF http://goo.gl/nzEIOe

  15. Concurrency in one GIF “Concurrency is about dealing with lots

    of things at once” -- Rob Pike
  16. Concurrency using Generators and Promises

  17. Promises Everyday

  18. Promises Everyday

  19. Promises Everyday

  20. Promises Everyday

  21. Promises Are awesome - Cleaner method signatures - Uniform return/error

    semantics - Easy composition - Easy sequential/parallel join - Always async - Exception-style error bubbling credit: http://www.slideshare.net/domenicdenicola/callbacks-promises-and-coroutines-oh-my-the-evolution-of-asynchronicity-in-javascript
  22. Promises and Generators Forbes Lindesay: Promises and Generators: control flow

    utopia -- JSConf EU 2013 http://www.youtube.com/watch?v=qbKWsbJ76-s http://pag.forbeslindesay.co.uk/#/
  23. Concurrency using Generator and Channels

  24. Channels Go-style concurrency

  25. Channels defined by CSP http://en.wikipedia.org/wiki/Communicating_sequential_processes

  26. Channels defined by CSP http://en.wikipedia.org/wiki/Communicating_sequential_processes “formal language for describing patterns

    of interaction in concurrent systems”
  27. Channels CSP implementations

  28. Channels Go-style concurrency

  29. Concurrency using Generator and Channels Producer

  30. Channels Producer

  31. Channels Producer

  32. Channels Producer

  33. Concurrency using Generator and Channels Consumer

  34. Channels Consumer

  35. Channels Consumer

  36. I Want to use Javascript NOW

  37. ES6 with Node

  38. ES6 In the browser

  39. ES6 In the browser

  40. ES6 In the browser

  41. Questions? Twitter @filippovitale BitBucket: filippovitale GitHub: filippovitale

  42. Thank you! Twitter @filippovitale BitBucket / GitHub: filippovitale

  43. Resources in random order - http://swannodette.github.io/2013/08/02/100000-processes/ - http://swannodette.github.io/2013/08/23/make-no-promises/ - http://swannodette.github.io/2013/08/24/es6-generators-and-csp/

    - http://concur.rspace.googlecode.com/hg/talk/concur.html#title-slide - http://stackoverflow.com/q/1050222/81444 - http://kangax.github.io/es5-compat-table/es6/ - http://wiki.ecmascript.org/doku.php?id=harmony:generators - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators - http://www.slideshare.net/domenicdenicola/es6-the-awesome-parts - http://www.youtube.com/watch?v=qbKWsbJ76-s - http://pag.forbeslindesay.co.uk/#/ - http://www.slideshare.net/domenicdenicola/callbacks-promises-and-cor
  44. f in