JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 20
  • Score
    100M100P100Q47781F
  • License MIT

it binds methods to its class prototype + Compatible with stub/spy used on unit-test frameworks (Sinon.Js, enzyme,...so on) + Can be integrated with 3rd party decorators (like @autobind decorator)

Package Exports

  • babel-autobind

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (babel-autobind) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Build Status Coverage Status

Overview

it binds methods to its class prototype + Compatible with stub/spy used on unit-test frameworks (Sinon.Js, enzyme,...so on) + Can be worked together with other 3rd party decorators (like autobind-decorator)

Basic Example :

import {Autobind} from 'babel-autobind';

@Autobind
 class MyComponent extends React.Component {

 }
 export default MyComponent;

Or

import {Autobind} from 'babel-autobind';

 class MyComponent extends React.Component {

 }
 export default Autobind(MyComponent);

@Autobind decorator is more elegant than Autobind(...) function , However , Autobind(...) function is overloaded . Indeed, it accepts 2nd argument to rename the class after binding.

Example

import {Autobind} from 'babel-autobind';

 class MyComponent extends React.Component {

 }
 export default Autobind(MyComponent,'YourComponent');