UNPKG

@gongt/ts-stl-client

Version:
41 lines 1.51 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const React = require("react"); /* do not use this, without special problem */ class StatefulBaseComponent extends React.Component { constructor(props, context) { super(props, context); // console.log('constructor of', this.constructor.name); if (this.constructor.hasOwnProperty('_bindingMethods')) { this.constructor['_bindingMethods'].forEach((name) => { this[name] = this[name].bind(this); }); } this.afterConstruct(props, context); } afterConstruct(props, context) { } } exports.StatefulBaseComponent = StatefulBaseComponent; /** Redux base component */ class BaseComponent extends StatefulBaseComponent { } exports.BaseComponent = BaseComponent; function BindThis(target, propertyKey, descriptor) { if (descriptor === undefined) { throw new TypeError('@BindThis only allow to decorate method.'); } if (!target.constructor.hasOwnProperty('_bindingMethods')) { Object.defineProperty(target.constructor, '_bindingMethods', { configurable: true, enumerable: false, value: [], }); } target.constructor['_bindingMethods'].push(propertyKey); // console.log('BindThis of', target.constructor.name); // console.log(target.constructor['_bindingMethods']); return descriptor; } exports.BindThis = BindThis; //# sourceMappingURL=stateless-component.js.map