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

Stream removes itself upon destruction #609

Merged
merged 2 commits into from
Mar 23, 2017

Conversation

briancaine
Copy link
Contributor

@briancaine briancaine commented Mar 23, 2017

Fixes issue #500.

test/test.js Outdated
@@ -2864,6 +2864,16 @@ exports['wrap EventEmitter (or jQuery) on handler'] = function (test) {
});
};

exports['removing EventEmitter (or jQuery) listener on destruction'] = function(test) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you make a note of the original issue? Just append " (issue #500)" to the end.

Copy link
Contributor Author

@briancaine briancaine Mar 23, 2017

Choose a reason for hiding this comment

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

Here? Issue #500

I tagged it in the pull request.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry, I meant in the test name. LIke this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, gotcha.

test/test.js Outdated
var ee = new EventEmitter();
var s = _('myevent', ee);

test.same(typeof ee._events.myevent, 'function');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Checking private state like _events is brittle. You should listen to the 'removeListener' event instead, and make sure that is is emitted when you destroy the stream.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

lib/index.js Outdated
};

secondArg.on(xs, callback_func);
var removeMethod = secondArg.removeListener || secondArg.unbind;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add a comment that says which method belongs to which type of event emitters (EventEmitter or jQuery)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@vqvu
Copy link
Collaborator

vqvu commented Mar 23, 2017

LGTM.

@vqvu vqvu merged commit 8d19fe1 into caolan:master Mar 23, 2017
@briancaine briancaine deleted the bugfix/remove_listener_destructor branch March 23, 2017 02:47
vqvu added a commit that referenced this pull request Mar 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants