EventTarget 与 Event API
稳定性: 1 - 实验
EventTarget
和 Event
对象是一些 Node.js 核心 API 暴露的 EventTarget
Web API 的特定于 Node.js 的实现。
EventTarget
和 Event
类都不可用于创建最终用户代码。
const target = getEventTargetSomehow();
target.addEventListener('foo', (event) => {
console.log('foo event happened!');
});
Stability: 1 - Experimental
The EventTarget
and Event
objects are a Node.js-specific implementation
of the EventTarget
Web API that are exposed by some Node.js core APIs.
Neither the EventTarget
nor Event
classes are available for end
user code to create.
const target = getEventTargetSomehow();
target.addEventListener('foo', (event) => {
console.log('foo event happened!');
});