SlideShare a Scribd company logo
1 of 13
Download to read offline
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,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"!
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)
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
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
};
)
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;
};
)
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;
};
)
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
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.
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
template.html!
QUESTIONS?

More Related Content

What's hot

File-I/O -- ist doch ganz einfach, oder?
File-I/O -- ist doch ganz einfach, oder?File-I/O -- ist doch ganz einfach, oder?
File-I/O -- ist doch ganz einfach, oder?Christian Kauhaus
 
Automated tests - facts and myths
Automated tests - facts and mythsAutomated tests - facts and myths
Automated tests - facts and mythsWojciech Sznapka
 
Os Practical Assignment 1
Os Practical Assignment 1Os Practical Assignment 1
Os Practical Assignment 1Emmanuel Garcia
 
Python and rust 2018 pythonkorea jihun
Python and rust 2018 pythonkorea jihunPython and rust 2018 pythonkorea jihun
Python and rust 2018 pythonkorea jihunJIHUN KIM
 
Comunicação Bluetooth Entre Python e PyS60
Comunicação Bluetooth Entre Python e PyS60Comunicação Bluetooth Entre Python e PyS60
Comunicação Bluetooth Entre Python e PyS60Felipe Ronchi Brigido
 
システムコールトレーサーの動作原理と実装 (Writing system call tracer for Linux/x86)
システムコールトレーサーの動作原理と実装 (Writing system call tracer for Linux/x86)システムコールトレーサーの動作原理と実装 (Writing system call tracer for Linux/x86)
システムコールトレーサーの動作原理と実装 (Writing system call tracer for Linux/x86)Masashi Shibata
 
it's only abuse if it crashes
it's only abuse if it crashesit's only abuse if it crashes
it's only abuse if it crashesEleanor McHugh
 
CentOS_slide_ver1.0
CentOS_slide_ver1.0CentOS_slide_ver1.0
CentOS_slide_ver1.0Satoshi Kume
 
מודלים חישוביים - תרגול מס 2 - אוניברסיטת חיפה
   מודלים חישוביים - תרגול מס 2 - אוניברסיטת חיפה    מודלים חישוביים - תרגול מס 2 - אוניברסיטת חיפה
מודלים חישוביים - תרגול מס 2 - אוניברסיטת חיפה Igor Kleiner
 
strace for Perl Mongers
strace for Perl Mongersstrace for Perl Mongers
strace for Perl MongersNaosuke Yokoe
 

What's hot (19)

Clojure入門
Clojure入門Clojure入門
Clojure入門
 
File-I/O -- ist doch ganz einfach, oder?
File-I/O -- ist doch ganz einfach, oder?File-I/O -- ist doch ganz einfach, oder?
File-I/O -- ist doch ganz einfach, oder?
 
Yg byev2e
Yg byev2eYg byev2e
Yg byev2e
 
gemdiff
gemdiffgemdiff
gemdiff
 
Automated tests - facts and myths
Automated tests - facts and mythsAutomated tests - facts and myths
Automated tests - facts and myths
 
Os Practical Assignment 1
Os Practical Assignment 1Os Practical Assignment 1
Os Practical Assignment 1
 
Python and rust 2018 pythonkorea jihun
Python and rust 2018 pythonkorea jihunPython and rust 2018 pythonkorea jihun
Python and rust 2018 pythonkorea jihun
 
New
NewNew
New
 
System adm
System admSystem adm
System adm
 
Dicas de SSH
Dicas de SSHDicas de SSH
Dicas de SSH
 
Comunicação Bluetooth Entre Python e PyS60
Comunicação Bluetooth Entre Python e PyS60Comunicação Bluetooth Entre Python e PyS60
Comunicação Bluetooth Entre Python e PyS60
 
システムコールトレーサーの動作原理と実装 (Writing system call tracer for Linux/x86)
システムコールトレーサーの動作原理と実装 (Writing system call tracer for Linux/x86)システムコールトレーサーの動作原理と実装 (Writing system call tracer for Linux/x86)
システムコールトレーサーの動作原理と実装 (Writing system call tracer for Linux/x86)
 
it's only abuse if it crashes
it's only abuse if it crashesit's only abuse if it crashes
it's only abuse if it crashes
 
CentOS_slide_ver1.0
CentOS_slide_ver1.0CentOS_slide_ver1.0
CentOS_slide_ver1.0
 
3-in-1 YSlow
3-in-1 YSlow3-in-1 YSlow
3-in-1 YSlow
 
Tic tac toe
Tic tac toeTic tac toe
Tic tac toe
 
מודלים חישוביים - תרגול מס 2 - אוניברסיטת חיפה
   מודלים חישוביים - תרגול מס 2 - אוניברסיטת חיפה    מודלים חישוביים - תרגול מס 2 - אוניברסיטת חיפה
מודלים חישוביים - תרגול מס 2 - אוניברסיטת חיפה
 
strace for Perl Mongers
strace for Perl Mongersstrace for Perl Mongers
strace for Perl Mongers
 
Basics
BasicsBasics
Basics
 

Similar to Node.js Flow Control with SEQ

2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices
2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices
2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best PracticesJohannes Hoppe
 
Asynchronous java script
Asynchronous java scriptAsynchronous java script
Asynchronous java scriptRon Martin
 
Nginx Scripting - Extending Nginx Functionalities with Lua
Nginx Scripting - Extending Nginx Functionalities with LuaNginx Scripting - Extending Nginx Functionalities with Lua
Nginx Scripting - Extending Nginx Functionalities with LuaTony Fabeen
 
Devinsampa nginx-scripting
Devinsampa nginx-scriptingDevinsampa nginx-scripting
Devinsampa nginx-scriptingTony Fabeen
 
SecureSocial - Authentication for Play Framework
SecureSocial - Authentication for Play FrameworkSecureSocial - Authentication for Play Framework
SecureSocial - Authentication for Play Frameworkjaliss
 
Build a custom (micro)framework with ZF2 Components (as building blocks)
Build a custom (micro)framework with ZF2 Components (as building blocks)Build a custom (micro)framework with ZF2 Components (as building blocks)
Build a custom (micro)framework with ZF2 Components (as building blocks)Corley S.r.l.
 
How to create a 3.2 billion dollar business in 20 minutes: combining AngularJ...
How to create a 3.2 billion dollar business in 20 minutes: combining AngularJ...How to create a 3.2 billion dollar business in 20 minutes: combining AngularJ...
How to create a 3.2 billion dollar business in 20 minutes: combining AngularJ...Ari Lerner
 
Creating windows store java script apps
Creating windows store java script appsCreating windows store java script apps
Creating windows store java script appsEugene Zharkov
 
nescala 2013
nescala 2013nescala 2013
nescala 2013Hung Lin
 
Learn Frontend Testing
Learn Frontend TestingLearn Frontend Testing
Learn Frontend TestingRyan Roemer
 
Building modern web apps with html5, javascript, and java
Building modern web apps with html5, javascript, and javaBuilding modern web apps with html5, javascript, and java
Building modern web apps with html5, javascript, and javaAlexander Gyoshev
 
A Backbone.js Tutorial for the Impatient - Part 1
A Backbone.js Tutorial for the Impatient - Part 1A Backbone.js Tutorial for the Impatient - Part 1
A Backbone.js Tutorial for the Impatient - Part 1jsalonen Salonen
 
Beginner workshop to angularjs presentation at Google
Beginner workshop to angularjs presentation at GoogleBeginner workshop to angularjs presentation at Google
Beginner workshop to angularjs presentation at GoogleAri Lerner
 
PhpUnit Best Practices
PhpUnit Best PracticesPhpUnit Best Practices
PhpUnit Best PracticesEdorian
 
The Browser Environment - A Systems Programmer's Perspective
The Browser Environment - A Systems Programmer's PerspectiveThe Browser Environment - A Systems Programmer's Perspective
The Browser Environment - A Systems Programmer's PerspectiveEleanor McHugh
 
Advanced QUnit - Front-End JavaScript Unit Testing
Advanced QUnit - Front-End JavaScript Unit TestingAdvanced QUnit - Front-End JavaScript Unit Testing
Advanced QUnit - Front-End JavaScript Unit TestingLars Thorup
 

Similar to Node.js Flow Control with SEQ (20)

2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices
2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices
2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices
 
Asynchronous java script
Asynchronous java scriptAsynchronous java script
Asynchronous java script
 
Nginx Scripting - Extending Nginx Functionalities with Lua
Nginx Scripting - Extending Nginx Functionalities with LuaNginx Scripting - Extending Nginx Functionalities with Lua
Nginx Scripting - Extending Nginx Functionalities with Lua
 
Devinsampa nginx-scripting
Devinsampa nginx-scriptingDevinsampa nginx-scripting
Devinsampa nginx-scripting
 
SecureSocial - Authentication for Play Framework
SecureSocial - Authentication for Play FrameworkSecureSocial - Authentication for Play Framework
SecureSocial - Authentication for Play Framework
 
Build a custom (micro)framework with ZF2 Components (as building blocks)
Build a custom (micro)framework with ZF2 Components (as building blocks)Build a custom (micro)framework with ZF2 Components (as building blocks)
Build a custom (micro)framework with ZF2 Components (as building blocks)
 
How to create a 3.2 billion dollar business in 20 minutes: combining AngularJ...
How to create a 3.2 billion dollar business in 20 minutes: combining AngularJ...How to create a 3.2 billion dollar business in 20 minutes: combining AngularJ...
How to create a 3.2 billion dollar business in 20 minutes: combining AngularJ...
 
Creating windows store java script apps
Creating windows store java script appsCreating windows store java script apps
Creating windows store java script apps
 
Hazelcast - In-Memory DataGrid
Hazelcast - In-Memory DataGridHazelcast - In-Memory DataGrid
Hazelcast - In-Memory DataGrid
 
JavaScript pitfalls
JavaScript pitfallsJavaScript pitfalls
JavaScript pitfalls
 
JavaFX, because you're worth it
JavaFX, because you're worth itJavaFX, because you're worth it
JavaFX, because you're worth it
 
nescala 2013
nescala 2013nescala 2013
nescala 2013
 
Learn Frontend Testing
Learn Frontend TestingLearn Frontend Testing
Learn Frontend Testing
 
Building modern web apps with html5, javascript, and java
Building modern web apps with html5, javascript, and javaBuilding modern web apps with html5, javascript, and java
Building modern web apps with html5, javascript, and java
 
A Backbone.js Tutorial for the Impatient - Part 1
A Backbone.js Tutorial for the Impatient - Part 1A Backbone.js Tutorial for the Impatient - Part 1
A Backbone.js Tutorial for the Impatient - Part 1
 
Ff to-fp
Ff to-fpFf to-fp
Ff to-fp
 
Beginner workshop to angularjs presentation at Google
Beginner workshop to angularjs presentation at GoogleBeginner workshop to angularjs presentation at Google
Beginner workshop to angularjs presentation at Google
 
PhpUnit Best Practices
PhpUnit Best PracticesPhpUnit Best Practices
PhpUnit Best Practices
 
The Browser Environment - A Systems Programmer's Perspective
The Browser Environment - A Systems Programmer's PerspectiveThe Browser Environment - A Systems Programmer's Perspective
The Browser Environment - A Systems Programmer's Perspective
 
Advanced QUnit - Front-End JavaScript Unit Testing
Advanced QUnit - Front-End JavaScript Unit TestingAdvanced QUnit - Front-End JavaScript Unit Testing
Advanced QUnit - Front-End JavaScript Unit Testing
 

Recently uploaded

Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 

Recently uploaded (20)

Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 

Node.js Flow Control with SEQ

  • 2. ABOUT ME Who I am: Douglas Muth How to contact me: dmuth@dmuth.org / @dmuth What I do: Software Engineer ...mostly.
  • 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"!
  • 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. 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. 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. 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. 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. 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. FURTHER READING The Seq repo: https://github.com/substack/node-seq/
  • 12. ON THE WEB https://github.com/dmuth/nodejs-presentations Feel free to clone and add your own presentations based off of template.html!