1.1.3 • Published 2 years ago

@nfq/autobind v1.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@nfq/autobind

EsLint License: MIT


  1. Description
  2. Getting started
    1. Installation
  3. Usage
  4. Support

Description: License: MIT

The @nfq/autobind package provides a decorator function for automatically binding class methods to the instance of the class. This ensures the correct context (this value) is maintained, especially useful when passing methods as callbacks. It is designed to streamline method binding in JavaScript and TypeScript applications, particularly beneficial in React components and other class-based structures.


Getting started

To install the package locally follow the next steps:

Installation

To install the package run

npm install @nfq/autobind

if you are on yarn

yarn add @nfq/autobind

or on pnpm

pnpm install @nfq/autobind

Usage

The @autobind decorator can be used in class components to ensure that methods are bound to the instance of the class. This is especially useful when passing methods as callbacks.

import {autobind} from '@nfq/autobind';

class MyClass {
  @autobind
  myMethod() {
    // This method is automatically bound to instances of MyClass.
  }
}

Support

Christoph Kruppe - https://github.com/ckruppe - c.kruppe@nfq.de

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago