Slide 1

Slide 1 text

Asynchronous JavaScript

Slide 2

Slide 2 text

What is asynchronous JavaScript ? JS is actually single threaded and is mostly synchronous Async things are: ● AJAX calls ● Events

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

Asynchronous Synchronous 2 waiting 1 3 4 2 waiting 1 3 4

Slide 5

Slide 5 text

/******************************************************************************************** For example, if you go down to a fast food joint and order a cheeseburger they will immediately take your order and then make you wait around until the cheeseburger is ready. In the meantime they can take other orders and start cooking cheeseburgers for other people. Imagine if you had to wait at the register for your cheeseburger, blocking all other people in line from ordering while they cooked your burger! This is called blocking I/O because all I/O (cooking cheeseburgers) happens one at a time. Node, on the other hand, is non-blocking, which means it can cook many cheeseburgers at once. ********************************************************************************************/ https://github.com/maxogden/art-of-node

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

So… How do you make the code behave?

Slide 8

Slide 8 text

Callbacks

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

Any Questions?