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

enhance: Off removes all listeners for EventEmitter #227

Merged
merged 3 commits into from
Feb 9, 2016

Conversation

mattheworiordan
Copy link
Member

@mattheworiordan
Copy link
Member Author

cc @tcard FYI in regards to the discussion at https://github.com/ably/ably-ios/pull/179/files#r51544655

} else if (Utils.isObject(listeners)) {
/* events */
for (eventName in listeners) {
if (listeners.hasOwnProperty(eventName) && Utils.isArray(listeners[eventName])) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not delete listeners[eventName] if it is empty after the remove operation.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it need to be deleted?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes of course. If an app for example continuously uses new randomly generated event names and then discards the listeners, the size of the events object will grow indefinitely. It's easy to re-add.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes of course. If an app for example continuously uses new randomly generated event names and then discards the listeners, the size of the events object will grow indefinitely. It's easy to re-add.

Ah, good point, I will make that change.

@paddybyers
Copy link
Member

LGTM apart from the comment above.

Also, someone needs to take these tests: https://github.com/ably/realtime/blob/master/test/util/eventemitter.js and migrate them.

@mattheworiordan
Copy link
Member Author

@paddybyers fixed with 4f50db9

@paddybyers
Copy link
Member

fixed with 4f50db9

LGTM

tcard added a commit to ably/ably-cocoa that referenced this pull request Feb 8, 2016
@mattheworiordan mattheworiordan merged commit 3092796 into master Feb 9, 2016
@mattheworiordan mattheworiordan deleted the event-emitter-spec-clarity branch February 9, 2016 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants