Binds all the class methods to their instances in your components.
- Polyfill for the implementations that do not natively support bind().
- Not necessarily binds the lifecycle hooks to the class instance.
npm install --save cmp-bind
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.
npm run test
Add unit tests for any new or changed functionality.
ISC