GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — events: Loop forwards to find listener in removeListener function · Issue #21635 · nodejs/node Closed Labels docIssues and PRs related to Node.js documentation.Issues and PRs related to Node.js documentation.eventsIssues and PRs related to EventEmitter and the events module.Issues and PRs related to EventEmitter and the events module. Description
const EventEmitter = require('events') function pong () { console.log('pong') } let a = new EventEmitter() a.once('ping', pong) a.on('ping', pong) a.removeListener('ping', pong) a.emit('ping') a.emit('ping') // output: // pong let b = new EventEmitter() b.on('ping', pong) b.once('ping', pong) b.removeListener('ping', pong) b.emit('ping') b.emit('ping') // output: // pong // pong The output shows that for multiple same listeners, the last added one will be the first to remove (LIFO). I think maybe a "FIFO" logic is better for this case. And I find the commit on 5 Mar 2013 which implements "loop backwards" logic. Reacted by Balint Soos Activity
MetadataMetadataAssigneesLabelsdocIssues and PRs related to Node.js documentation.Issues and PRs related to Node.js documentation.eventsIssues and PRs related to EventEmitter and the events module.Issues and PRs related to EventEmitter and the events module. TypeProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |