Skip to content

Commit

Permalink
use local this variable instead of .bind
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris authored Feb 23, 2018
1 parent 389b5c9 commit 957179f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions store.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,14 @@ assign(Store.prototype, {

onchange: function(callback) {
this._changeHandlers.push(callback);

var store = this;

return {
cancel: function() {
var index = this._changeHandlers.indexOf(callback);
if (~index) this._changeHandlers.splice(index, 1);
}.bind(this)
var index = store._changeHandlers.indexOf(callback);
if (~index) store._changeHandlers.splice(index, 1);
}
};
},

Expand Down

0 comments on commit 957179f

Please sign in to comment.