在 JavaScript 中,使用 bind() 删除作为事件侦听器添加的函数的最佳方法是什么?
例子
(function(){
    // constructor
    MyClass = function() {
        this.myButton = document.getElementById("myButtonID");
        this.myButton.addEventListener("click", this.clickListener.bind(this));
    };
    MyClass.prototype.clickListener = function(event) {
        console.log(this); // must be MyClass
    };
    // public method
    MyClass.prototype.disableButton = function() {
        this.myButton.removeEventListener("click", ___________);
    };
})();
我能想到的唯一方法是跟踪每个添加了 bind 的监听器。
上面这个方法的例子:
(function(){
    // constructor
    MyClass = function() {
        this.myButton = document.getElementById("myButtonID");
        this.clickListenerBind = this.clickListener.bind(this);
        this.myButton.addEventListener("click", this.clickListenerBind);
    };
    MyClass.prototype.clickListener = function(event) {
        console.log(this); // must be MyClass
    };
    // public method
    MyClass.prototype.disableButton = function() {
        this.myButton.removeEventListener("click", this.clickListenerBind);
    };
})();
有没有更好的方法来做到这一点?