Search the reference...
/
BuildDocsReferenceGuidesBlogDiscord/node:events/default/onFonfunction
events.default.on { ee.emit('foo', 'bar'); ee.emit('foo', 42); }); for await (const event of on(ee, 'foo')) { // The execution of this inner block is synchronous and it // processes one event at a time (even with await). Do not use // if concurrent execution is required. console.log(event); // prints ['bar'] [42] } // Unreachable here ``` Returns an `AsyncIterator` that iterates `eventName` events. It will throw if the `EventEmitter` emits `'error'`. It removes all listeners when exiting the loop. The `value` returned by each iteration is an array composed of the emitted event arguments. An `AbortSignal` can be used to cancel waiting on events: ```js import { on, EventEmitter } from 'node:events'; import process from 'node:process'; const ac = new AbortController(); (async () => { const ee = new EventEmitter(); // Emit later on process.nextTick(() => { ee.emit('foo', 'bar'); ee.emit('foo', 42); }); for await (const event of on(ee, 'foo', { signal: ac.signal })) { // The execution of this inner block is synchronous and it // processes one event at a time (even with await). Do not use // if concurrent execution is required. console.log(event); // prints ['bar'] [42] } // Unreachable here })(); process.nextTick(() => ac.abort()); ```" data-algolia-static="false" data-algolia-merged="false" data-type="Function">function on(emitter: EventEmitter,eventName: string | symbol,options?: OnOptions): AsyncIteratorany[]>;import { on, EventEmitter } from 'node:events'; import process from 'node:process'; const ee = new EventEmitter(); // Emit later on process.nextTick(() => { ee.emit('foo', 'bar'); ee.emit('foo', 42); }); for await (const event of on(ee, 'foo')) { // The execution of this inner block is synchronous and it // processes one event at a time (even with await). Do not use // if concurrent execution is required. console.log(event); // prints ['bar'] [42] } // Unreachable here Returns an AsyncIterator that iterates eventName events. It will throw if the EventEmitter emits 'error'. It removes all listeners when exiting the loop. The value returned by each iteration is an array composed of the emitted event arguments.An AbortSignal can be used to cancel waiting on events:import { on, EventEmitter } from 'node:events'; import process from 'node:process'; const ac = new AbortController(); (async () => { const ee = new EventEmitter(); // Emit later on process.nextTick(() => { ee.emit('foo', 'bar'); ee.emit('foo', 42); }); for await (const event of on(ee, 'foo', { signal: ac.signal })) { // The execution of this inner block is synchronous and it // processes one event at a time (even with await). Do not use // if concurrent execution is required. console.log(event); // prints ['bar'] [42] } // Unreachable here })(); process.nextTick(() => ac.abort()); @returnsAsyncIterator that iterates eventName events emitted by the emitterfunction on(emitter: EventTarget,eventName: string,options?: OnOptions): AsyncIteratorany[]>;import { on, EventEmitter } from 'node:events'; import process from 'node:process'; const ee = new EventEmitter(); // Emit later on process.nextTick(() => { ee.emit('foo', 'bar'); ee.emit('foo', 42); }); for await (const event of on(ee, 'foo')) { // The execution of this inner block is synchronous and it // processes one event at a time (even with await). Do not use // if concurrent execution is required. console.log(event); // prints ['bar'] [42] } // Unreachable here Returns an AsyncIterator that iterates eventName events. It will throw if the EventEmitter emits 'error'. It removes all listeners when exiting the loop. The value returned by each iteration is an array composed of the emitted event arguments.An AbortSignal can be used to cancel waiting on events:import { on, EventEmitter } from 'node:events'; import process from 'node:process'; const ac = new AbortController(); (async () => { const ee = new EventEmitter(); // Emit later on process.nextTick(() => { ee.emit('foo', 'bar'); ee.emit('foo', 42); }); for await (const event of on(ee, 'foo', { signal: ac.signal })) { // The execution of this inner block is synchronous and it // processes one event at a time (even with await). Do not use // if concurrent execution is required. console.log(event); // prints ['bar'] [42] } // Unreachable here })(); process.nextTick(() => ac.abort()); @returnsAsyncIterator that iterates eventName events emitted by the emitterReferenced typesclass EventTargetEventTarget is a DOM interface implemented by objects that can receive events and may have listeners for them.MDN ReferenceaddEventListener(type: string,callback: null | EventListenerOrEventListenerObject,options?: boolean | AddEventListenerOptions): void;Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture.When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners.When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted.The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture.MDN ReferenceaddEventListener(type: string,listener: EventListener | EventListenerObject,options?: boolean | AddEventListenerOptions): void;Adds a new handler for the type event. Any given listener is added only once per type and per capture option value.If the once option is true, the listener is removed after the next time a type event is dispatched.The capture option is not used by Node.js in any functional way other than tracking registered event listeners per the EventTarget specification. Specifically, the capture option is used as part of the key when registering a listener. Any individual listener may be added once with capture = false, and once with capture = true.dispatchEvent(event: Event): boolean;Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.removeEventListener(type: string,callback: null | EventListenerOrEventListenerObject,options?: boolean | EventListenerOptions): void;Removes the event listener in target's event listener list with the same type, callback, and options.MDN ReferenceremoveEventListener(type: string,listener: EventListener | EventListenerObject,options?: boolean | EventListenerOptions): void;Removes the event listener in target's event listener list with the same type, callback, and options.Resources
ReferenceDocsGuidesDiscordMerch StoreGitHubBlogToolkit
RuntimePackage managerTest runnerBundlerPackage runnerProject
Bun 1.0Bun 1.1Bun 1.2Bun 1.3RoadmapContributingLicenseBaked with ❤️ in San FranciscoWe're hiring →智能索引记录
-
2026-03-03 09:16:18
教育培训
成功
标题:五年级的作文7篇(精华)
简介:在平时的学习、工作或生活中,大家都跟作文打过交道吧,作文是通过文字来表达一个主题意义的记叙方法。那么你有了解过作文吗?以
-
2026-03-03 00:08:42
博客创作
成功
标题:收集:笔记(贫民窟-5)_消逝的光芒 图文全攻略 全主支线任务全剧情全收集品_3DM单机
简介:《消逝的光芒》图文全攻略(系统详细教程/全技能解析+全主线支线任务流程/全剧情+全稀有蓝紫橙蓝图/日志/笔记/邮件/雕像
-
2026-03-02 23:50:17
综合导航
成功
标题:残尘逸仙全本最新章节_第二十章 灭宗第1页_残尘逸仙全本免费章节_恋上你看书网
简介:第二十章 灭宗第1页_残尘逸仙全本_落日鹰眼_恋上你看书网
-
2026-03-03 09:12:09
综合导航
成功
标题:DS7.3 for Windows 10 ELE International
简介:Browse our range of DS7.3 for Windows 10 online. ELE Interna
-
2026-03-03 00:25:22
综合导航
成功
标题:超级教师最新章节_092章 亦天豪的设想三更第1页_超级教师免费章节_恋上你看书网
简介:092章 亦天豪的设想三更第1页_超级教师_梁天成_恋上你看书网
-
2026-03-03 03:34:10
综合导航
成功
标题:Schaeffler Germany
简介:Schaeffler has been driving forward groundbreaking invention
-
2026-03-02 19:14:18
综合导航
成功
标题:Platoon
简介:Platoon est un film réalisé par Oliver Stone avec Charlie Sh
-
2026-03-03 00:17:15
综合导航
成功
标题:江澄主角最新章节_江澄主角全文免费阅读_恋上你看书网
简介:关于江澄一世唤长安:江澄,二十一世纪有为男青年,墨香铜臭的忠实追随者。一朝穿越,成为中人人嫌弃的直男江晚吟,调换视角才发
-
2026-03-03 00:53:21
游戏娱乐
成功
标题:点缀小蛋糕,点缀小蛋糕小游戏,4399小游戏 www.4399.com
简介:点缀小蛋糕在线玩,点缀小蛋糕下载, 点缀小蛋糕攻略秘籍.更多点缀小蛋糕游戏尽在4399小游戏,好玩记得告诉你的朋友哦!
-
2026-03-03 00:07:16
综合导航
成功
标题:财运 第32页 - 吉吉算命网
简介:财运 第32页_吉吉算命网
-
2026-03-03 00:19:14
综合导航
成功
标题:Sereno Edwards Dwight (1786-1850). The Reader's Biographical Encyclopaedia. 1922
简介:Sereno Edwards Dwight (1786-1850). The Reader
-
2026-03-02 23:53:36
综合导航
成功
标题:ä¸æèæºçæ¼é³_ä¸æèæºçææ_ä¸æèæºçç¹ä½_è¯ç»ç½
简介:è¯ç»ç½ä¸æèæºé¢é,ä»ç»ä¸æèæº,ä¸æèæºç
-
2026-03-03 11:43:23
综合导航
成功
标题:字典_词典_成语_诗词名句-雄安文学网
简介:雄安文学网为您提供新华字典在线查字,支持部首拼音笔画多种查字法。成语解释,成语出处,成语接接龙,古诗词翻译古诗词朗诵,各
-
2026-03-03 09:08:51
综合导航
成功
标题:Free Nature Coloring Page - Lake with Duck EDU.COM
简介:Free printable nature coloring page of lake with duck for gr
-
2026-03-02 12:01:02
视频影音
成功
标题:美剧TV_免费美国电视剧_高清美剧在线观看_美剧网
简介:美剧TV美剧网是中文最大的美剧视频网站,专注于为美剧迷提供最新美剧在线观看,同时整理了美剧排行榜、美剧大全、好看的美剧、
-
2026-03-02 23:58:12
综合导航
成功
标题:品牌官网案例深圳市施尔洁生物工程有限公司-网站建设案例-深圳网站建设公司网联科技
简介:深圳市施尔洁生物工程有限公司,致力于消毒产品的研发和推广。拥有年产值2亿元的十万级净化消毒生产厂房、十条生产线、七十多台
-
2026-03-03 00:50:05
新闻资讯
成功
标题:大数据战略需要数据中心基础架构作出的改变有哪些?, 站长资讯平台
简介:为大数据选择新的硬件、存储和其它数据中心基础设施,这是IT专业人员们所面临的新挑战。推行大数据战略的压力往往来自高层,因
-
2026-03-02 18:58:03
综合导航
成功
标题:xBrokers Trading Zone Launches Trial Run: From Token Listing to Ecosystem Verification for Real Stock Trading Bee Network
简介:Trial operation arrangements During the trial operation ph
-
2026-03-02 18:40:14
游戏娱乐
成功
标题:过年坐火车回家,过年坐火车回家小游戏,4399小游戏 www.4399.com
简介:过年坐火车回家在线玩,过年坐火车回家下载, 过年坐火车回家攻略秘籍.更多过年坐火车回家游戏尽在4399小游戏,好玩记得告
-
2026-03-02 18:56:26
综合导航
成功
标题:Interpretation: Musk founded the American Party, Trump commented that it was absurd Bee Network
简介:Original Odaily Planet Daily ( @OdailyChina ) Author: Wen
-
2026-03-03 08:57:32
金融理财
成功
标题:银华基金于蕾:打造“固收+”的平台生态系统 科创债 资产配置 公募基金 银行理财_网易订阅
简介:银华基金于蕾:打造“固收+”的平台生态系统,于蕾,科创债,银华基金,资产配置,公募基金,银行理财
-
2026-03-03 00:11:08
综合导航
成功
标题:KrisFlyer新航集團獎勵計劃
简介:With KrisFlyer, experiences are miles better. Earn miles to
-
2026-03-02 19:05:34
图片素材
成功
标题:人生的作文550字 描写人生的作文 关于人生的作文-作文网
简介:作文网精选关于人生的550字作文,包含人生的作文素材,关于人生的作文题目,以人生为话题的550字作文大全,作文网原创名师
-
2026-03-02 12:17:29
综合导航
成功
标题:Candy Line - Play The Free Mobile Game Online
简介:Candy Line - click to play online. Select a candy you want t
-
2026-03-02 23:44:12
综合导航
成功
标题:Antoine Louis Claude, Comte Destutt de Tracy (1754-1836). The Reader's Biographical Encyclopaedia. 1922
简介:Antoine Louis Claude, Comte Destutt de Tracy (1754-1836). Th
-
2026-03-02 20:59:55
综合导航
成功
标题:解梦 第53页 - 吉吉算命网
简介:解梦 第53页_吉吉算命网
-
2026-03-03 11:23:55
综合导航
成功
标题:Pump Science Bee Network
简介:Platform penelitian umur panjang yang di-gamifikasi. Berspek
-
2026-03-02 20:44:21
综合导航
成功
标题:NVE Corp- AG956-07E: ASR002-10E Smart SPI Angle Sensor Evaluation Kit -
简介:This is AG956-07E: ASR002-10E Smart SPI Angle Sensor Evaluat
-
2026-03-02 20:49:43
综合导航
成功
标题:† Browdster. World English Historical Dictionary
简介:† Browdster. World English Historical Dictionary
-
2026-03-03 11:38:10
教育培训
成功
标题:写网络的作文600字7篇
简介:在日常的学习、工作、生活中,大家最不陌生的就是作文了吧,作文根据体裁的不同可以分为记叙文、说明文、应用文、议论文。如何写