Skip to content
This repository was archived by the owner on Nov 3, 2021. It is now read-only.
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions lib/chuckt.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,23 @@ window.epixa || (window.epixa = {});
*
* @param event
*/
ChuckT.prototype.removeListeners = function(event) {
ChuckT.prototype.removeListeners = function(event, callback) {
if (typeof event === 'undefined') {
this.listeners = {};
} else {
delete this.listeners[event];
if (typeof listener !== "undefined") {
Copy link
Owner

Choose a reason for hiding this comment

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

Did you mean typeof callback here?

Also, can you update the comment for this function to include the additional argument as well as details for how the argument is used.

Copy link
Author

Choose a reason for hiding this comment

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

Oops, nice catch! I'll get this fixed up.

var len = this.listeners[event].length;

for (var i = 0; i < len; i ++) {
if (this.listeners[event][i] === callback) {
this.listeners[event].splice(i, 1);
len --;
i --;
}
}
} else {
delete this.listeners[event];
}
}
};

Expand Down