Non-Blocking Code

  • "Non-Blocking code starts a task and then gives instructions about what to do next"
  • Only asynchronous tasks need this kind of thought
  • More complicated code
function processFile() {
    readFile("budget.txt", checkExpenses);
}

function checkExpenses(fileData) {
    const largestExpense = determineLargestExpense(fileData);
    updateNetwork(largestExpense, printSuccess);
}

function printSuccess() {
    console.log("Done processing.")
}

18 / 27