react-application-core
Version:
A react-based application core for the business applications.
104 lines • 4.24 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.EnhancedGenericComponent = void 0;
var R = require("ramda");
var util_1 = require("../../util");
var generic_component_1 = require("./generic.component");
var di_1 = require("../../di");
var EnhancedGenericComponent = /** @class */ (function (_super) {
__extends(EnhancedGenericComponent, _super);
/**
* @stable [19.09.2020]
* @param originalProps
*/
function EnhancedGenericComponent(originalProps) {
var _this = _super.call(this, originalProps) || this;
_this.plugins = [];
_this.initPlugins();
return _this;
}
/**
* @stable [19.09.2020]
*/
EnhancedGenericComponent.prototype.componentDidMount = function () {
this.plugins.forEach(function (plugin) { return util_1.TypeUtils.isFn(plugin.componentDidMount) && plugin.componentDidMount(); });
};
/**
* @stable [21.04.2020]
*/
EnhancedGenericComponent.prototype.componentWillUnmount = function () {
this.plugins.forEach(function (plugin) { return util_1.TypeUtils.isFn(plugin.componentWillUnmount) && plugin.componentWillUnmount(); });
};
/**
* @stable [19.09.2020]
* @param prevProps
* @param prevState
* @param prevContext
*/
EnhancedGenericComponent.prototype.componentDidUpdate = function (prevProps, prevState, prevContext) {
this.plugins.forEach(function (plugin) { return util_1.TypeUtils.isFn(plugin.componentDidUpdate) && plugin.componentDidUpdate(prevProps, prevState, prevContext); });
};
/**
* @stable [19.09.2020]
* @param prevProps
* @param prevState
*/
EnhancedGenericComponent.prototype.getSnapshotBeforeUpdate = function (prevProps, prevState) {
this.plugins.forEach(function (plugin) {
return util_1.TypeUtils.isFn(plugin.getSnapshotBeforeUpdate) && plugin.getSnapshotBeforeUpdate(prevProps, prevState);
});
return null;
};
/**
* @stable [19.09.2020]
* @param pluginObject
*/
EnhancedGenericComponent.prototype.registerPlugin = function (pluginObject) {
if (R.isNil(pluginObject)) {
return;
}
this.plugins.push(util_1.TypeUtils.isFn(pluginObject)
? Reflect.construct(pluginObject, [this])
: pluginObject);
};
/**
* @stable [21.04.2020]
*/
EnhancedGenericComponent.prototype.initPlugins = function () {
var _this = this;
var plugins = this.uiPlugins;
if (!util_1.ObjectUtils.isObjectEmpty(plugins)) {
var dynamicPluginsFactories = plugins.get(this.constructor);
if (util_1.ObjectUtils.isObjectNotEmpty(dynamicPluginsFactories)) {
dynamicPluginsFactories.forEach(function (dynamicPluginFactory) { return _this.registerPlugin(dynamicPluginFactory(_this)); });
}
}
[].concat(this.props.plugins || []).forEach(this.registerPlugin, this);
};
Object.defineProperty(EnhancedGenericComponent.prototype, "uiPlugins", {
/**
* @stable [19.09.2020]
*/
get: function () {
return this.$uiPlugins = this.$uiPlugins || di_1.getUiPlugins();
},
enumerable: false,
configurable: true
});
return EnhancedGenericComponent;
}(generic_component_1.GenericComponent));
exports.EnhancedGenericComponent = EnhancedGenericComponent;
//# sourceMappingURL=enhanced-generic.component.js.map