- Mastering Node.js(Second Edition)
- Sandro Pasquali Kevin Faaborg
- 257字
- 2021-07-02 19:28:43
Listening for events
Modern network software, for various reasons, is growing in complexity and, in many ways, changing how we think about application development. Most new platforms and languages are attempting to address these changes. Node is no exception — and JavaScript is no exception.
Learning about Node means learning about event-driven programming, composing software out of modules, creating and linking data streams, and producing and consuming events and their related data. Node-based architectures are often composed of many small processes and/or services communicating with events — internally, by extending the EventEmitter interface and using callbacks, and externally, over one of several common transport layers (for example, HTTP, TCP), or through a thin messaging layer covering one of these transport layers (for example, 0MQ, Redis PUBSUB, and Kafka).
It is likely that these processes are composed of several free, open source, and high-quality npm modules, each distributed with unit tests and/or examples and/or documentation.
The previous chapter introduced you to the EventEmitter interface. This is the primary event interface we will be encountering as we move chapter to chapter, as it provides the prototype class for the many Node objects exposing evented interfaces, such as file and network streams. Various close, exit, data, and other events exposed by different module APIs signal the presence of an EventEmitter interface, and we will be learning about these modules and use cases as we progress.
In this section, our goal is to discuss some lesser-known event sources: signals, child process communication, filesystem change events, and deferred execution.
- 網絡協議工程
- MERN Quick Start Guide
- 從區塊鏈到Web3:構建未來互聯網生態
- Hands-On Chatbots and Conversational UI Development
- Hands-On Full Stack Development with Spring Boot 2 and React(Second Edition)
- 局域網組建、管理與維護項目教程(Windows Server 2003)
- 物聯網時代
- 智慧光網絡:關鍵技術、應用實踐和未來演進
- 物聯網長距離無線通信技術應用與開發
- 新手易學:新手學淘寶開店
- 通信十年:擁抱互聯網
- 人人都該都懂的互聯網思維
- 5G時代的大數據技術架構和關鍵技術詳解
- 一本書讀懂TCP/IP
- Dart Cookbook