Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

events: fix not emit removeListener #31846

Closed
wants to merge 1 commit into from
Closed

events: fix not emit removeListener #31846

wants to merge 1 commit into from

Conversation

fuxingZhang
Copy link
Contributor

Fix not emit removeListener when type of eventName is 'symbol'

const EventEmitter = require('events');
const myEmitter = new EventEmitter();
const sym = Symbol('symbol');
const fn = () => { };
myEmitter.on(sym, fn);

myEmitter.on('removeListener', (...args) => {
  console.log('removeListener');
  console.log(args, args[0] === sym, args[1] === fn);
});

myEmitter.removeAllListeners()
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

Fix not emit removeListener  when type of eventName is 'symbol'

```js
const EventEmitter = require('events');
const myEmitter = new EventEmitter();
const sym = Symbol('symbol');
const fn = () => { };
myEmitter.on(sym, fn);

myEmitter.on('removeListener', (...args) => {
  console.log('removeListener');
  console.log(args, args[0] === sym, args[1] === fn);
});

myEmitter.removeAllListeners()
```
@nodejs-github-bot nodejs-github-bot added the events Issues and PRs related to the events subsystem / EventEmitter. label Feb 18, 2020
@addaleax
Copy link
Member

Superseded by #31847

@fuxingZhang Just for the future, you can always push new commits to a PR to make changes that you like instead of opening a new PR :)

@fuxingZhang
Copy link
Contributor Author

Superseded by #31847

@fuxingZhang Just for the future, you can always push new commits to a PR to make changes that you like instead of opening a new PR :)

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
events Issues and PRs related to the events subsystem / EventEmitter.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants