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

Symbol-keys are ignored when using pair events #23

Closed
mistadikay opened this issue Jul 11, 2015 · 3 comments
Closed

Symbol-keys are ignored when using pair events #23

mistadikay opened this issue Jul 11, 2015 · 3 comments
Labels

Comments

@mistadikay
Copy link

Hi there,

just noticed you've added Symbol support. There is one bug though when using pair events like this:

myEmitter.on({
  myEvent1: function(e) {  },
  myEvent2: function(e) {  }
});

Since Symbols can not be enumerated with for ... in or Object.keys(events).on they are just being ignored in such cases.

Sorry, I don't have time for a proper PR, but here is a possible solution

// instead of using `for ... in` you can process each key type individually

// Symbol-keys
Object.getOwnPropertySymbols(events).forEach(function(event){
     // this.on/off/etc....
});

// String-keys
Object.getOwnPropertyNames(events).forEach(function(event){
     // this.on/off/etc....
});
@Yomguithereal
Copy link
Collaborator

Thanks @mistadikay. I'll try to fix this in a near future.

@Yomguithereal
Copy link
Collaborator

Hello @mistadikay. The last commit should have fixed the problem. I am releasing a 3.1.1 very soon.

@mistadikay
Copy link
Author

@Yomguithereal that's awesome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants