April 2018
Beginner
536 pages
13h 21m
English
Earlier in this chapter, we learned how the reactor pattern and the non-blocking I/O model are two of the most fundamental characteristics of Node.js. This should help us to understand why callbacks are used so extensively in the entire Node.js core API. As we can imagine, the core API has a direct impact on all the other modules. As a result, the entire Node.js ecosystem uses callbacks extensively.
Node.js not only uses callbacks extensively, but it also uses them in a very consistent way:
The following code snippet uses the filesystem API to read a text file. The readFile function ...