Getting Started With Node - JS: Paul O'Fallon @paulofallon
Getting Started With Node - JS: Paul O'Fallon @paulofallon
js
Paul O’Fallon
@paulofallon
Outline
An overview of Node.js
Building and installing Node.js
Developing for Node with Cloud9 IDE
An introduction to Node’s event loop
Writing code with callbacks
Node.js background
Node.js Building Blocks
http://nodejs.org/download/
Installers available for Windows & Mac OS X
Binaries available for Windows, Mac, Linux and SunOS
Also available via many Linux package managers
Source code also available
http://c9.io
Node’s Event Loop
timers filesystem
tcp
process
http
events network
What does this mean in practice?
Database
http request #1
http request #2
http response #1
http request #3
http response #2
http response #3
Writing asynchronous code is different
A typical approach
getStuff(inputParam, handleResults);
someOtherFunction(function(err, stuffToGet) {
var foo = 23;
getStuff(stuffToGet, function(error, results) {
// if error is undefined…
// do something with the results (and foo)
});
});
Too much of a good thing…