-
Notifications
You must be signed in to change notification settings - Fork 147
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
Stream removes itself upon destruction #609
Conversation
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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'); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
LGTM. |
Fixes issue #500.