utilizes.bind
v1.2.1
Published
Bind all methods of the given object to the object
Downloads
4
Readme
bind
Bind all methods of the given object to the object
Usage: bind(this): this
import { bind } from 'utilizes.bind'
class CoolService {
constructor() {
bind(this) // binding this via utilizes.bind
}
count = 0
increment() {
this.count++
}
}
const coolService = new CoolService()
const increment = coolService.increment
increment() // 'this.count++' point to coolService.count
console.log(coolService.count)
// Output: 1
This module exported from utilizes project.