1.0.3 • Published 3 years ago

sky-bind v1.0.3

Weekly downloads
14
License
-
Repository
github
Last release
3 years ago

sky-bind

Bind all your class methods with one line.

Install

npm install sky-bind

Usage

import { bindAll } from "sky-bind";

class A {
  name = "A";

  constructor() {
    bindAll(this); // done, all your class methods have bind this already.
    // this.onclick = this.onclick.bind(this); // that's no need here
  }

  onclick() {
    console.log("hello", this.name); // this will always pointer to this A instance
  }
}
1.0.3

3 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago