Bind event handlers to this less verbose
$ npm install bind-handler
var bindHandler = require('bind-handler');
class A {
constructor() {
bindHandler(this);
}
handleClick() {
// handler-prefix methods will be auto bound to this
// Just like this.handleClick = this.handleClick.bind(this)
}
otherClick() {
// other methods will not be auto bound to this
}
}
//=>
MIT © C.T. Lin