Skip to content

nitin42/component-bind

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

component-bind

Build Status

Binds all the class methods to their instances in your components.

Details

  • Polyfill for the implementations that do not natively support bind().
  • Not necessarily binds the lifecycle hooks to the class instance.

Install

npm install --save cmp-bind

Usage

const binder = require('cmp-bind');

class App {
  constructor(name) {
    this.name = name || null,
    binder(this); // Call here
  };

  component() {
    return `${this.name}`
  }

  error() {
    return `I am not a comp.`;
  }
}

const child = new App('Component');

const logger = child.component;
console.log(logger()); // Component

const error = child.error;
console.log(error()) // I am not a comp.

Tests

npm run test

Contributing

Add unit tests for any new or changed functionality.

License

ISC

About

Binds all the class methods to their instances in your component.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published