- Mastering Node.js(Second Edition)
- Sandro Pasquali Kevin Faaborg
- 304字
- 2021-07-02 19:28:41
Understanding Asynchronous Event-Driven Programming
"The best way to predict the future is to invent it."
– Alan Kay
Eliminating blocking processes through the use of event-driven, asynchronous I/O is Node's primary organizational principle. We've learned how this design helps developers in shaping information and adding capacity. Node lets you build and organize lightweight, independent, and share-nothing processes that communicate through callbacks and synchronize with a predictable event loop.
Accompanying the growth in the popularity of Node is a growth in the number of well-designed event-driven systems and applications. For a new technology to be successful, it must eliminate the existing problems, and/or offer to consumers a better solution at a lower cost in terms of time, effort, or price. In its young and fertile lifespan, the Node community has collaboratively proven that this new development model is a viable alternative to the existing technologies. The number and quality of Node-based solutions powering enterprise-level applications provides further proof that these new ideas are not only novel, but preferred.
In this chapter, we will delve deeper into how Node implements event-driven programming. We will begin by unpacking the ideas and theories that event-driven languages and environments derive from and grapple with, in an effort to clear away misconceptions and encourage mastery. Following this introduction to events, we'll look at the key Node.js technology—the event loop. We'll then go into more detail on how Node implements timers, callbacks, and I/O events, and how you as a Node developer can use them. We'll further discuss management of concurrency using modern tools such as Promises, Generators, and async/await. We'll practice the theory as we build up some simple but exemplary file and data-driven applications. These examples highlight Node's strengths, and show how Node is succeeding in its ambition to simplify network application designs.
- Building E-commerce Sites with VirtueMart Cookbook
- 社交電商運(yùn)營策略、技巧與實(shí)操
- 互聯(lián)網(wǎng)安全的40個(gè)智慧洞見:2015年中國互聯(lián)網(wǎng)安全大會文集
- 2小時(shí)讀懂物聯(lián)網(wǎng)
- 新手易學(xué):新手學(xué)淘寶開店
- 物聯(lián)網(wǎng)與智能家居
- 沖擊:5G如何改變世界
- Dart Cookbook
- 華為HCIA-Datacom認(rèn)證指南
- 移動互聯(lián)網(wǎng)新思維
- Enterprise ApplicationDevelopment with Ext JSand Spring
- 計(jì)算機(jī)通信網(wǎng)絡(luò)安全
- 物聯(lián)網(wǎng)
- 人際網(wǎng)絡(luò)
- ElasticSearch Server