diff options
Diffstat (limited to 'node_modules/auto-bind/readme.md')
-rw-r--r-- | node_modules/auto-bind/readme.md | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/node_modules/auto-bind/readme.md b/node_modules/auto-bind/readme.md index 8c375df9c..a40bcc43a 100644 --- a/node_modules/auto-bind/readme.md +++ b/node_modules/auto-bind/readme.md @@ -6,7 +6,7 @@ ## Install ``` -$ npm install --save auto-bind +$ npm install auto-bind ``` @@ -20,6 +20,7 @@ class Unicorn { this.name = name; autoBind(this); } + message() { return `${this.name} is awesome!`; } @@ -42,7 +43,7 @@ message(); ## API -### autoBind(self) +### autoBind(self, [options]) Bind methods in `self` to their class instance. Returns the `self` object. @@ -52,6 +53,37 @@ Type: `Object` Object with methods to bind. +#### options + +Type: `Object` + +##### include + +Type: `Array<string|RegExp>` + +Bind only the given methods. + +##### exclude + +Type: `Array<string|RegExp>` + +Bind methods except for the given methods. + +### autoBind.react(self, [options]) + +Same as `autoBind`, but excludes the default [React component methods](https://reactjs.org/docs/react-component.html). + +```js +class Foo extends React.Component { + constructor(props) { + super(props); + autoBind.react(this); + } + + // … +} +``` + ## Related |