@turbox3d/command-manager
Version:
Large-scale productivity application command management library
30 lines • 1.52 kB
JavaScript
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
import _inherits from "@babel/runtime/helpers/esm/inherits";
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
import { Command } from './Command';
/**
* 构建一个组合了其他 Command 的结构(本质依然是一个 Command)
*/
function compose(declaredMap) {
return /*#__PURE__*/function (_Command) {
function _class(holer, parent) {
var _this;
_classCallCheck(this, _class);
_this = _callSuper(this, _class, [holer, parent]);
// 构建 $children
Object.keys(declaredMap).forEach(function (key) {
var command = new declaredMap[key](_this.holder, _this);
_this[key] = command;
_this.$children[key] = command;
});
return _this;
}
_inherits(_class, _Command);
return _createClass(_class);
}(Command);
}
export { compose };