0
PRESENTING:
SEQ
ABOUT ME
Who I am: Douglas Muth
How to contact me: dmuth@dmuth.org / @dmuth
What I do: Software Engineer ...mostly.
THE PROBLEM
Flow control in node.js.
Node.js is a callback-heavy language.
Often, it looks like this:
d.ur(SLC ..,fnto(ro,...
SEQ 101
INSTALLATION
$nmisalsq
p ntl e

That was easy!
SEQ 101
USAGE
vrsq=rqie"e";
a e
eur(sq)
sq)sqfnto( {
e(.e(ucin)
d.ur(SLC ..,ti)
bqey"EET ." hs;
}.e(ucinrsls {
)sqfnto(eut...
SEQ 101
WHEN THINGS GO WRONG
sq)sqfnto( {
e(.e(ucin)
d.ur(SLC ..,ti)
bqey"EET ." hs;
}.e(ucinrsls {
)sqfnto(eut)
ti(e Err"...
HOW TO SEQ
IT'S A TRAP!
sq)sqfnto( {
e(.e(ucin)
d.ur(SLC ..,ti)
bqey"EET ." hs;
}.e(ucinrsls {
)sqfnto(eut)
sq)sqfnto( {
e...
SEQ 101
SAFE NESTING OF SEQ
sq)sqfnto( {
e(.e(ucin)
d.ur(SLC ..,ti)
bqey"EET ." hs;
}.e(ucinrsls {
)sqfnto(eut)
vrc =ti;/ ...
ADVANCED SEQ
vrf =rqie's)
a s
eur(f';
vree =rqie'hl_rcs'.xc
a xc
eur(cidpoes)ee;
vrSq=rqie'e';
a e
eur(sq)
Sq)
e(
.e(ucins...
EVEN MORE SEQ
Process an array of elements:
forEach()
seqEach()
parEach()
Play around with "this":
this.stack
this.vars
th...
FURTHER READING
The Seq repo:
https://github.com/substack/node-seq/
ON THE WEB
https://github.com/dmuth/nodejs-presentations
Feel free to clone and add your own presentations based off of
te...
QUESTIONS?
Upcoming SlideShare
Loading in...5
×

Presenting Seq for Node.js

457

Published on

An overview of Seq, a flow control module for node.js

Published in: Technology, Business
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
457
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
3
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "Presenting Seq for Node.js"

  1. 1. PRESENTING: SEQ
  2. 2. ABOUT ME Who I am: Douglas Muth How to contact me: dmuth@dmuth.org / @dmuth What I do: Software Engineer ...mostly.
  3. 3. THE PROBLEM Flow control in node.js. Node.js is a callback-heavy language. Often, it looks like this: d.ur(SLC ..,fnto(ro,rsls { bqey"EET ." ucinerr eut) i (err { f !ro) d.ur(UDT ..,fnto(ro,rsls { bqey"PAE ." ucinerr eut) i (err { f !ro) d.ur(ISR ..,fnto(ro,rsls { bqey"NET ." ucinerr eut) / O Gd wy / h o, h? } } }; ) } }; ) Also known as "boomerang code"!
  4. 4. SEQ 101 INSTALLATION $nmisalsq p ntl e That was easy!
  5. 5. SEQ 101 USAGE vrsq=rqie"e"; a e eur(sq) sq)sqfnto( { e(.e(ucin) d.ur(SLC ..,ti) bqey"EET ." hs; }.e(ucinrsls { )sqfnto(eut) d.ur(UDT ..,ti) bqey"PAE ." hs; }.e(ucinrsls { )sqfnto(eut) d.ur(ISR ..,ti) / Pet set bqey"NET ." hs; / rty we! }; ) "this()" is the callback which goes to the next block of code
  6. 6. SEQ 101 WHEN THINGS GO WRONG sq)sqfnto( { e(.e(ucin) d.ur(SLC ..,ti) bqey"EET ." hs; }.e(ucinrsls { )sqfnto(eut) ti(e Err"hk tig u altl") hsnw ro(Sae hns p ite); }.e(ucinrsls { )sqfnto(eut) / Ti wl nvrrn / hs il ee u d.ur(ISR ..,ti) bqey"NET ." hs; }.ac(ucinerr { )cthfnto(ro) / Igtti! / o hs }; )
  7. 7. HOW TO SEQ IT'S A TRAP! sq)sqfnto( { e(.e(ucin) d.ur(SLC ..,ti) bqey"EET ." hs; }.e(ucinrsls { )sqfnto(eut) sq)sqfnto( { e(.e(ucin) / D smtig / o oehn }.e(ucin){ )sqfnto( / D smtiges / o oehn le / Ti wntg t teotrSq / hs o' o o h ue e ti(; hs) }.e(ucin){ )sqfnto( / Ti gt cle b acdn / hs es ald y ciet }; ) }.e(ucinrsls { )sqfnto(eut) / Ti wl nvrrn / hs il ee u d.ur(ISR ..,ti) bqey"NET ." hs; }; )
  8. 8. SEQ 101 SAFE NESTING OF SEQ sq)sqfnto( { e(.e(ucin) d.ur(SLC ..,ti) bqey"EET ." hs; }.e(ucinrsls { )sqfnto(eut) vrc =ti;/ ti( b ayohrnm. a b hs / hs) y n te ae. sq)sqfnto( { e(.e(ucin) / D smtig / o oehn }.e(ucin){ )sqfnto( / D smtiges / o oehn le / Ti wntg t teotrSq / hs o' o o h ue e c(; b) }.e(ucin){ )sqfnto( / Ti nvrgt cle / hs ee es ald }; ) }.e(ucinrsls { )sqfnto(eut) / Ti gt cle / hs es ald d.ur(ISR ..,ti) bqey"NET ." hs; }; )
  9. 9. ADVANCED SEQ vrf =rqie's) a s eur(f'; vree =rqie'hl_rcs'.xc a xc eur(cidpoes)ee; vrSq=rqie'e'; a e eur(sq) Sq) e( .e(ucinse1){ sqfnto tp( ee(wom' ti) xc'hai, hs } ) .a(ucinse2wo { prfnto tp(h) ee(gop '+wo ti) xc'rus h, hs; } ) .a(ucinse3wo { prfnto tp(h) f.edie_flnm,'si' ti) sraFl(_ieae aci, hs; } ) .e(ucinse4gop,sc { sqfnto tp(rus r) cnoelg'rus '+gop.rm); osl.o(Gop: rusti() cnoelg'hsfl hs'+sclnt +'bts) osl.o(Ti ie a r.egh ye'; } ) ; Order of execution is as follows: step1() step2() and step3() are executed in parallel step4() ONLY when step2() and step3() complete
  10. 10. EVEN MORE SEQ Process an array of elements: forEach() seqEach() parEach() Play around with "this": this.stack this.vars this.into(key) this.args Not for the faint of heart, and WAY beyond the scope of this presentation.
  11. 11. FURTHER READING The Seq repo: https://github.com/substack/node-seq/
  12. 12. ON THE WEB https://github.com/dmuth/nodejs-presentations Feel free to clone and add your own presentations based off of template.html!
  13. 13. QUESTIONS?
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×