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

Javascript ES6 Generators & Thunks

Avatar for Brad Olson Brad Olson
September 04, 2014

Javascript ES6 Generators & Thunks

A very terse slide set on Generators and Thunks I made in 20 minutes when the scheduled speaker couldn't come...

Avatar for Brad Olson

Brad Olson

September 04, 2014

Other Decks in Programming

Transcript

  1. Must read: rvagg async: Why bother: "Async programming: Accept it.

    It's the new norm." Write your own Async.js. https://github.com/rvagg/asynchronous-javascript-patterns
  2. r e a d F i l e C P

    S ( f i l e n a m e , e n c o d i n g , f u n c t i o n ( e r r , r e s u l t ) { . . . } ) ; r e t u r n m e a n s s h o r t c i r c u i t r e a d F i l e P r o m i s e ( f i l e n a m e , e n c o d i n g ) - > t h e n a b l e r e t u r n o b j e c t . t h e n ( s u c c e s s ( d a t a ) , f a i l u r e ( e r r ) ) ; r e a d F i l e T h u n k ( f i l e n a m e , e n c o d i n g ) - > c o n t i n u a b l e r e t u r n f u n c t i o n ( c a l l b a c k ( e r r , r e s u l t ) ) ;
  3. c o ( f u n c t i o

    n * ( ) { v a r a = y i e l d g e t ( ' h t t p : / / g o o g l e . c o m ' ) ; v a r b = y i e l d g e t ( ' h t t p : / / y a h o o . c o m ' ) ; v a r c = y i e l d g e t ( ' h t t p : / / c l o u d u p . c o m ' ) ; c o n s o l e . l o g ( a [ 0 ] . s t a t u s C o d e ) ; c o n s o l e . l o g ( b [ 0 ] . s t a t u s C o d e ) ; c o n s o l e . l o g ( c [ 0 ] . s t a t u s C o d e ) ; } ) ( ) ;