O'Reilly logo

CoffeeScript in Action by Patrick Lee

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 9. Composing the asynchronous

This chapter covers

  • The limits of processing data synchronously
  • How an event loop works and why you need to think asynchronously
  • Events as data and data as events
  • Event emitters and how to compose event streams

Remember imperative programs? They’re a bit like the list of chores that Scruffy’s mum used to leave him:

  • Clean your room
  • Take out the trash
  • Do your homework
  • No games until you finish your chores!

Scruffy could do the chores in any order, but he couldn’t play until the chores were finished. If everything is synchronous, then games just go after chores:

chores()
games()

You’ve learned about things that are asynchronous. If Scruffy pays Agtron to do his chores, then he can start his games ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required