utilizes.bind
TypeScript icon, indicating that this package has built-in type declarations

1.2.1 • Public • Published

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.

Readme

Keywords

Package Sidebar

Install

npm i utilizes.bind

Weekly Downloads

1

Version

1.2.1

License

MIT

Unpacked Size

53.4 kB

Total Files

5

Last publish

Collaborators

  • natqe3