Hey libuv, can you please read this file for me? Oh and when you are done, call cbSettingsRead

Our code
      // Load the filesystem library
var fs = require('fs')

function readSettingsFile() {
  // Write code to read the file.
  // Callback called once done.
  fs.readFile("settings.json", cbSettingsRead);
}

function cbSettingsRead(err, data) {
  if(err) {
    // There was an error while
    // reading the file.
  } else {
    // File was read, update the settings.
  }
}

function initDefaultSettings() {
  // Initialize default settings.
}

readSettingsFile();
initDefaultSettings();
    
  1. readSettingsFile is called by V8.
  2. fs.readFile is called by V8.
  3. v8 then runs initDefaultSettings.
  4. libuv tries to reads the file.
  5. libuv calls cbSettingsRead with the result.

OK, sure!
Send it over.

Download song
Read file
The Event Loop