Finish Your Node App - Table of Contents

What You Need to Know to Write Your First App 3

  • Initial User Code 3
  • Role of Node Programmer 3
  • System 5
  • Experiment 5

Exercise: Breathing Relaxation Method 6

System 9

  • System Calls Initial User Code 9
  • Waiting For Activity and Calling Registered Functions 10
  • Pseudo-code of System 10

Returning Control Back 12

  • Ways to Return Control Back 12

Exercise: Fix Broken Code 14

Reading Files 18

  • File Read Program 18
  • Call Returns Without Results 19
  • Function Is Called When Results Are In 19
  • Error Argument 19
  • Experiment 20

Exercise: File Hasher 21

Reading Code 26

  • Synchronously Called Function 26
  • Asynchronously Called Function 26
  • Experiment 27

Visualizing Program Execution 28

  • Visualizing First Program 28

Putting Dependent Logic Inside Callback 33

  • Reading Files 33
  • Making HTTP Calls 33
  • Experiment 34

Exercise: Twitter Weather Bot 35

Making Use of Waiting Time 40

  • Communicating with Network is Slow 40
  • Worker Threads 41
  • Making Use of Waiting Time 42
  • Experiment 43

Exercise: News Aggregator 44

Bonus: Caring for Other Computations 49

  • SetImmediate 49
  • Prime Numbers 49
  • Prime Numbers with Other Activity 50
  • Experiment 52

Bonus: Complete System 53

  • process.nextTick() 53
  • Complete System 53
  • Experiment 55