Comparing version 0.8.0 to 0.9.0
@@ -66,6 +66,43 @@ require("source-map-support").install(); | ||
var _channel = __webpack_require__(5); | ||
var _channel2 = _interopRequireDefault(_channel); | ||
var _inputChannel = __webpack_require__(4); | ||
var _inputChannel2 = _interopRequireDefault(_inputChannel); | ||
var _outputChannel = __webpack_require__(8); | ||
var _outputChannel2 = _interopRequireDefault(_outputChannel); | ||
var _channelManager = __webpack_require__(3); | ||
var _channelManager2 = _interopRequireDefault(_channelManager); | ||
var _request = __webpack_require__(10); | ||
var _request2 = _interopRequireDefault(_request); | ||
var _response = __webpack_require__(9); | ||
var _response2 = _interopRequireDefault(_response); | ||
var _channels = __webpack_require__(7); | ||
var CHANNEL = _interopRequireWildcard(_channels); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
exports.default = { | ||
Component: _component2.default | ||
Component: _component2.default, | ||
Channel: _channel2.default, | ||
InputChannel: _inputChannel2.default, | ||
OutputChannel: _outputChannel2.default, | ||
ChannelManager: _channelManager2.default, | ||
Request: _request2.default, | ||
Response: _response2.default, | ||
CHANNEL: CHANNEL | ||
}; | ||
@@ -85,16 +122,20 @@ | ||
var _root = __webpack_require__(3); | ||
var _channelManager = __webpack_require__(3); | ||
var _root2 = _interopRequireDefault(_root); | ||
var _channelManager2 = _interopRequireDefault(_channelManager); | ||
var _channelManager = __webpack_require__(5); | ||
var _inputChannel = __webpack_require__(4); | ||
var _channelManager2 = _interopRequireDefault(_channelManager); | ||
var _inputChannel2 = _interopRequireDefault(_inputChannel); | ||
var _parentChannelManager = __webpack_require__(7); | ||
var _callbackChannel = __webpack_require__(6); | ||
var _parentChannelManager2 = _interopRequireDefault(_parentChannelManager); | ||
var _callbackChannel2 = _interopRequireDefault(_callbackChannel); | ||
var _response = __webpack_require__(8); | ||
var _outputChannel = __webpack_require__(8); | ||
var _outputChannel2 = _interopRequireDefault(_outputChannel); | ||
var _response = __webpack_require__(9); | ||
var _response2 = _interopRequireDefault(_response); | ||
@@ -106,9 +147,9 @@ | ||
var _statuses = __webpack_require__(4); | ||
var _channels = __webpack_require__(7); | ||
var STATUS = _interopRequireWildcard(_statuses); | ||
var CHANNEL = _interopRequireWildcard(_channels); | ||
var _channels = __webpack_require__(9); | ||
var _errors = __webpack_require__(11); | ||
var CHANNEL = _interopRequireWildcard(_channels); | ||
var ERROR = _interopRequireWildcard(_errors); | ||
@@ -125,17 +166,9 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
this._parentChannelManager = new _parentChannelManager2.default(); | ||
this._channelManager = new _channelManager2.default(this); | ||
this._channelManager.createChannel(CHANNEL.DEFAULT_CHANNEL); | ||
this._status = STATUS.INIT; | ||
this._finalComponentFlag = false; | ||
this._rootComponent = new _root2.default(); | ||
this._rootComponent.addComponent(this); | ||
this._inputChannelManager = new _channelManager2.default(); | ||
this._outputChannelManager = new _channelManager2.default(); | ||
this.createInputChannel(CHANNEL.DEFAULT_CHANNEL); | ||
this.createOutputChannel(CHANNEL.DEFAULT_CHANNEL); | ||
this.onInit(options); | ||
} | ||
/** | ||
* for override | ||
* It is for initialize component | ||
*/ | ||
_createClass(Component, [{ | ||
@@ -145,95 +178,118 @@ key: "onInit", | ||
}, { | ||
key: "onProcess", | ||
value: function onProcess(request, response) { | ||
response.send(request.value); | ||
key: "onNext", | ||
value: function onNext(request, response) { | ||
response.send(request.getValue()); | ||
} | ||
/** | ||
* triggered once from root component. It start all process. | ||
* It need to have connection ready. | ||
* @returns Promise promise is resolved when every component in tree is done. | ||
*/ | ||
}, { | ||
key: "start", | ||
value: function start(value) { | ||
var targetChannelName = arguments.length <= 1 || arguments[1] === undefined ? CHANNEL.DEFAULT_CHANNEL : arguments[1]; | ||
}, { | ||
key: "run", | ||
value: function run(value, endCallback) { | ||
this._rootComponent.run(endCallback); | ||
this._runProcess([value]); | ||
return this.next(new _request2.default(value, null, this.getInputChannel(targetChannelName))); | ||
} | ||
/** | ||
* Start to run component logic from this.onProcess. | ||
*/ | ||
}, { | ||
key: "_runProcess", | ||
value: function _runProcess(parentResponseValueList) { | ||
key: "next", | ||
value: function next(request) { | ||
var _this = this; | ||
this._status = STATUS.PROCESS; | ||
var response = new _response2.default(this._getResponseCallback()); | ||
setTimeout(function () { | ||
return _this.onProcess(new _request2.default(parentResponseValueList), new _response2.default(_this)); | ||
return _this.onNext(request, response); | ||
}, 0); | ||
return this; | ||
} | ||
/** | ||
* When parent component is done, it inform his child components about it. Which allow them to start | ||
* By default child component start when all parent components are done. | ||
*/ | ||
}, { | ||
key: "addJoint", | ||
value: function addJoint(target) { | ||
var currentChannelName = arguments.length <= 1 || arguments[1] === undefined ? CHANNEL.DEFAULT_CHANNEL : arguments[1]; | ||
var targetChannelName = arguments.length <= 2 || arguments[2] === undefined ? CHANNEL.DEFAULT_CHANNEL : arguments[2]; | ||
}, { | ||
key: "onParentReady", | ||
value: function onParentReady() { | ||
if (this._parentChannelManager.isDone()) { | ||
this._runProcess(this._parentChannelManager.getChannelsValue()); | ||
var targetInput = target.getInputChannel(targetChannelName); | ||
var currentOutput = this.getOutputChannel(currentChannelName); | ||
if (targetInput.isChannel(currentOutput) === false && currentOutput.isChannel(targetInput) === false) { | ||
targetInput.addChannel(currentOutput); | ||
currentOutput.addChannel(targetInput); | ||
} else { | ||
throw Error(ERROR.ONE_JOINT_PER_CHANNEL_PAIR); | ||
} | ||
return this; | ||
} | ||
}, { | ||
key: "getChannel", | ||
value: function getChannel(channelName) { | ||
return this._channelManager.getChannel(channelName); | ||
key: "addCallback", | ||
value: function addCallback(target) { | ||
var currentChannelName = arguments.length <= 1 || arguments[1] === undefined ? CHANNEL.DEFAULT_CHANNEL : arguments[1]; | ||
var currentOutput = this.getOutputChannel(currentChannelName); | ||
currentOutput.addChannel(new _callbackChannel2.default(target)); | ||
return this; | ||
} | ||
}, { | ||
key: "createChannel", | ||
value: function createChannel(channelName) { | ||
this._channelManager.createChannel(channelName); | ||
key: "_getResponseCallback", | ||
value: function _getResponseCallback() { | ||
var _this2 = this; | ||
return function (value, channelName) { | ||
_this2.getOutputChannel(channelName).emitValue(value); | ||
}; | ||
} | ||
/** | ||
* If this method is triggered before component is done, it is flagged as final component, | ||
* this means that when it is done also component chain is done | ||
*/ | ||
}, { | ||
key: "isInputChannel", | ||
value: function isInputChannel() { | ||
var channelName = arguments.length <= 0 || arguments[0] === undefined ? CHANNEL.DEFAULT_CHANNEL : arguments[0]; | ||
return this._inputChannelManager.isChannelByName(channelName); | ||
} | ||
}, { | ||
key: "final", | ||
value: function final() { | ||
this._finalComponentFlag = true; | ||
return this; | ||
key: "isOutputChannel", | ||
value: function isOutputChannel() { | ||
var channelName = arguments.length <= 0 || arguments[0] === undefined ? CHANNEL.DEFAULT_CHANNEL : arguments[0]; | ||
return this._outputChannelManager.isChannelByName(channelName); | ||
} | ||
/** | ||
* bind parent component with this component | ||
* @param component parent component | ||
* @param channelName parent channel name | ||
*/ | ||
}, { | ||
key: "getInputChannel", | ||
value: function getInputChannel() { | ||
var channelName = arguments.length <= 0 || arguments[0] === undefined ? CHANNEL.DEFAULT_CHANNEL : arguments[0]; | ||
if (this.isInputChannel(channelName) === false) { | ||
throw Error(ERROR.NON_EXIST_CHANNEL); | ||
} | ||
return this._inputChannelManager.getChannel(channelName); | ||
} | ||
}, { | ||
key: "bind", | ||
value: function bind(parent, channelName) { | ||
channelName = channelName || CHANNEL.DEFAULT_CHANNEL; | ||
var parentChannel = parent.getChannel(channelName); | ||
this._parentChannelManager.addChannel(parentChannel); | ||
parentChannel.addComponent(this); | ||
parent.setChildRootComponent(this, this._rootComponent); | ||
key: "getOutputChannel", | ||
value: function getOutputChannel() { | ||
var channelName = arguments.length <= 0 || arguments[0] === undefined ? CHANNEL.DEFAULT_CHANNEL : arguments[0]; | ||
if (this.isOutputChannel(channelName) === false) { | ||
throw Error(ERROR.NON_EXIST_CHANNEL); | ||
} | ||
return this._outputChannelManager.getChannel(channelName); | ||
} | ||
}, { | ||
key: "setChildRootComponent", | ||
value: function setChildRootComponent(child, root) { | ||
this._rootComponent.merge(root); | ||
child.setRootComponent(this._rootComponent); | ||
key: "_getInputChannelSetValueCallback", | ||
value: function _getInputChannelSetValueCallback() { | ||
var _this3 = this; | ||
return function (value, sourceOutput, currentInput) { | ||
_this3.next(new _request2.default(value, sourceOutput, currentInput)); | ||
}; | ||
} | ||
}, { | ||
key: "setRootComponent", | ||
value: function setRootComponent(root) { | ||
this._rootComponent = root; | ||
key: "createInputChannel", | ||
value: function createInputChannel(channelName) { | ||
if (this.isInputChannel(channelName) === true) { | ||
throw Error(ERROR.UNIQUE_NAME_INPUT_CHANNEL); | ||
} | ||
this._inputChannelManager.addChannel(new _inputChannel2.default(channelName, this._getInputChannelSetValueCallback())); | ||
return this; | ||
} | ||
}, { | ||
key: "getStatus", | ||
value: function getStatus() { | ||
return this._status; | ||
key: "createOutputChannel", | ||
value: function createOutputChannel(channelName) { | ||
if (this.isOutputChannel(channelName) === true) { | ||
throw Error(ERROR.UNIQUE_NAME_OUTPUT_CHANNEL); | ||
} | ||
this._outputChannelManager.addChannel(new _outputChannel2.default(channelName)); | ||
return this; | ||
} | ||
@@ -249,3 +305,3 @@ }]); | ||
/* 3 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/***/ function(module, exports) { | ||
@@ -260,62 +316,50 @@ "use strict"; | ||
var _statuses = __webpack_require__(4); | ||
var STATUS = _interopRequireWildcard(_statuses); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var Root = function () { | ||
function Root() { | ||
_classCallCheck(this, Root); | ||
var ChannelManager = function () { | ||
function ChannelManager() { | ||
_classCallCheck(this, ChannelManager); | ||
this._components = []; | ||
this._status = STATUS.INIT; | ||
this._channels = []; | ||
} | ||
_createClass(Root, [{ | ||
key: "addComponent", | ||
value: function addComponent(component) { | ||
this._components.push(component); | ||
_createClass(ChannelManager, [{ | ||
key: "isChannelByName", | ||
value: function isChannelByName(channelName) { | ||
return typeof this.getChannel(channelName) !== "undefined"; | ||
} | ||
/** | ||
* triggered once from root component. It start all process. | ||
* It need to have connection ready. | ||
*/ | ||
}, { | ||
key: "run", | ||
value: function run(finishCallback) { | ||
this._finishCallback = finishCallback; | ||
this._status = STATUS.PROCESS; | ||
key: "isChannel", | ||
value: function isChannel(testChannel) { | ||
return this.getChannels().some(function (channel) { | ||
return channel === testChannel; | ||
}); | ||
} | ||
}, { | ||
key: "finish", | ||
value: function finish(output) { | ||
this._status = STATUS.DONE; | ||
if (this._finishCallback) { | ||
this._finishCallback(output); | ||
} | ||
key: "addChannel", | ||
value: function addChannel(channel) { | ||
this._channels.push(channel); | ||
} | ||
/** | ||
* allow to join two rootComponents to one | ||
* @param childRootComponent | ||
*/ | ||
}, { | ||
key: "merge", | ||
value: function merge(childRootComponent) { | ||
this._components = this._components.concat(childRootComponent.components); | ||
key: "getChannel", | ||
value: function getChannel(name) { | ||
return this._channels.find(function (channel) { | ||
return channel.getName() === name; | ||
}); | ||
} | ||
}, { | ||
key: "getChannels", | ||
value: function getChannels() { | ||
return this._channels; | ||
} | ||
}]); | ||
return Root; | ||
return ChannelManager; | ||
}(); | ||
exports.default = Root; | ||
exports.default = ChannelManager; | ||
/***/ }, | ||
/* 4 */ | ||
/***/ function(module, exports) { | ||
/***/ function(module, exports, __webpack_require__) { | ||
@@ -325,8 +369,51 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
var INIT = exports.INIT = "init"; | ||
var PROCESS = exports.PROCESS = "processing"; | ||
var DONE = exports.DONE = "done"; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _channel = __webpack_require__(5); | ||
var _channel2 = _interopRequireDefault(_channel); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
var InputChannel = function (_Channel) { | ||
_inherits(InputChannel, _Channel); | ||
function InputChannel(name, onSetValueCallback) { | ||
_classCallCheck(this, InputChannel); | ||
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(InputChannel).call(this, name)); | ||
if (onSetValueCallback) { | ||
_this.setCallback(onSetValueCallback); | ||
} | ||
return _this; | ||
} | ||
_createClass(InputChannel, [{ | ||
key: "setCallback", | ||
value: function setCallback(onSetValueCallback) { | ||
this._onSetValueCallback = onSetValueCallback; | ||
return this; | ||
} | ||
}, { | ||
key: "setValue", | ||
value: function setValue(value, sourceOutput) { | ||
this._onSetValueCallback(value, sourceOutput, this); | ||
} | ||
}]); | ||
return InputChannel; | ||
}(_channel2.default); | ||
exports.default = InputChannel; | ||
/***/ }, | ||
@@ -344,5 +431,5 @@ /* 5 */ | ||
var _channel = __webpack_require__(6); | ||
var _channelManager = __webpack_require__(3); | ||
var _channel2 = _interopRequireDefault(_channel); | ||
var _channelManager2 = _interopRequireDefault(_channelManager); | ||
@@ -353,28 +440,29 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var ChannelManager = function () { | ||
function ChannelManager(component) { | ||
_classCallCheck(this, ChannelManager); | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
this.component = component; | ||
this.channels = []; | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
var Channel = function (_ChannelManager) { | ||
_inherits(Channel, _ChannelManager); | ||
function Channel(name) { | ||
_classCallCheck(this, Channel); | ||
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Channel).call(this)); | ||
_this._name = name; | ||
return _this; | ||
} | ||
_createClass(ChannelManager, [{ | ||
key: "createChannel", | ||
value: function createChannel(name) { | ||
this.channels.push(new _channel2.default(this.component, name)); | ||
_createClass(Channel, [{ | ||
key: "getName", | ||
value: function getName() { | ||
return this._name; | ||
} | ||
}, { | ||
key: "getChannel", | ||
value: function getChannel(name) { | ||
return this.channels.find(function (channel) { | ||
return channel.name === name; | ||
}); | ||
} | ||
}]); | ||
return ChannelManager; | ||
}(); | ||
return Channel; | ||
}(_channelManager2.default); | ||
exports.default = ChannelManager; | ||
exports.default = Channel; | ||
@@ -393,40 +481,63 @@ /***/ }, | ||
var _statuses = __webpack_require__(4); | ||
var _inputChannel = __webpack_require__(4); | ||
var STATUS = _interopRequireWildcard(_statuses); | ||
var _inputChannel2 = _interopRequireDefault(_inputChannel); | ||
var _channels = __webpack_require__(7); | ||
var CHANNEL = _interopRequireWildcard(_channels); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var Channel = function () { | ||
function Channel(component, name) { | ||
_classCallCheck(this, Channel); | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
this.component = component; | ||
this.name = name; | ||
this.status = STATUS.INIT; | ||
this.connectedChildrenComponents = []; | ||
this.value = null; | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
var CallbackChannel = function (_InputChannel) { | ||
_inherits(CallbackChannel, _InputChannel); | ||
function CallbackChannel(onSetValueCallback) { | ||
_classCallCheck(this, CallbackChannel); | ||
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(CallbackChannel).call(this, CHANNEL.DEFAULT_CHANNEL)); | ||
_this.setCallback(onSetValueCallback); | ||
return _this; | ||
} | ||
_createClass(Channel, [{ | ||
key: "addComponent", | ||
value: function addComponent(component) { | ||
this.connectedChildrenComponents.push(component); | ||
_createClass(CallbackChannel, [{ | ||
key: "setCallback", | ||
value: function setCallback(onSetValueCallback) { | ||
this._callback = onSetValueCallback; | ||
return this; | ||
} | ||
}, { | ||
key: "getComponentList", | ||
value: function getComponentList() { | ||
return this.connectedChildrenComponents; | ||
key: "setValue", | ||
value: function setValue(value, sourceOutput) { | ||
this._callback(value, sourceOutput); | ||
} | ||
}]); | ||
return Channel; | ||
}(); | ||
return CallbackChannel; | ||
}(_inputChannel2.default); | ||
exports.default = Channel; | ||
exports.default = CallbackChannel; | ||
/***/ }, | ||
/* 7 */ | ||
/***/ function(module, exports) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var DEFAULT_CHANNEL = exports.DEFAULT_CHANNEL = "default"; | ||
/***/ }, | ||
/* 8 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
@@ -442,50 +553,42 @@ | ||
var _statuses = __webpack_require__(4); | ||
var _channel = __webpack_require__(5); | ||
var STATUS = _interopRequireWildcard(_statuses); | ||
var _channel2 = _interopRequireDefault(_channel); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var ParentChannelManager = function () { | ||
function ParentChannelManager() { | ||
_classCallCheck(this, ParentChannelManager); | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
this._channels = []; | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
var OutputChannel = function (_Channel) { | ||
_inherits(OutputChannel, _Channel); | ||
function OutputChannel(name) { | ||
_classCallCheck(this, OutputChannel); | ||
return _possibleConstructorReturn(this, Object.getPrototypeOf(OutputChannel).call(this, name)); | ||
} | ||
_createClass(ParentChannelManager, [{ | ||
key: "addChannel", | ||
value: function addChannel(channel) { | ||
this._channels.push(channel); | ||
} | ||
}, { | ||
key: "getChannelsValue", | ||
value: function getChannelsValue() { | ||
return this._channels.map(function (channel) { | ||
return channel.value; | ||
_createClass(OutputChannel, [{ | ||
key: "emitValue", | ||
value: function emitValue(value) { | ||
var _this2 = this; | ||
var outputs = this.getChannels(); | ||
outputs.forEach(function (channel) { | ||
channel.setValue(value, _this2); | ||
}); | ||
} | ||
}, { | ||
key: "isDone", | ||
value: function isDone() { | ||
var doneCount = this._channels.reduce(function (doneCount, channel) { | ||
if (channel.status === STATUS.DONE && channel.component.getStatus() === STATUS.DONE) { | ||
return ++doneCount; | ||
} else { | ||
return doneCount; | ||
} | ||
}, 0); | ||
return doneCount === this._channels.length; | ||
} | ||
}]); | ||
return ParentChannelManager; | ||
}(); | ||
return OutputChannel; | ||
}(_channel2.default); | ||
exports.default = ParentChannelManager; | ||
exports.default = OutputChannel; | ||
/***/ }, | ||
/* 8 */ | ||
/* 9 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
@@ -501,8 +604,4 @@ | ||
var _statuses = __webpack_require__(4); | ||
var _channels = __webpack_require__(7); | ||
var STATUS = _interopRequireWildcard(_statuses); | ||
var _channels = __webpack_require__(9); | ||
var CHANNEL = _interopRequireWildcard(_channels); | ||
@@ -514,67 +613,18 @@ | ||
/** | ||
* Object which is passed to component onProcess method. | ||
* It allow to set responses to channels of components and then pass it to child components in Request | ||
*/ | ||
var Response = function () { | ||
function Response(component) { | ||
function Response(onSendCallback) { | ||
_classCallCheck(this, Response); | ||
this._component = component; | ||
this._onSendCallback = onSendCallback; | ||
} | ||
_createClass(Response, [{ | ||
key: "init", | ||
value: function init() { | ||
this._component._channelManager.channels.forEach(function (channel) { | ||
channel.status = STATUS.INIT; | ||
channel.value = null; | ||
}); | ||
} | ||
}, { | ||
key: "prepare", | ||
value: function prepare(value, channelName) { | ||
if (this._component._rootComponent._status === STATUS.PROCESS) { | ||
channelName = channelName || CHANNEL.DEFAULT_CHANNEL; | ||
var channel = this._component.getChannel(channelName); | ||
channel.status = STATUS.DONE; | ||
channel.value = value; | ||
} | ||
} | ||
}, { | ||
key: "done", | ||
value: function done() { | ||
var _this = this; | ||
key: "send", | ||
value: function send() { | ||
var value = arguments.length <= 0 || arguments[0] === undefined ? undefined : arguments[0]; | ||
var channelName = arguments.length <= 1 || arguments[1] === undefined ? CHANNEL.DEFAULT_CHANNEL : arguments[1]; | ||
if (this._component._rootComponent._status === STATUS.PROCESS) { | ||
this._component._status = STATUS.DONE; | ||
if (this._component._finalComponentFlag === false) { | ||
this._component._channelManager.channels.forEach(function (channel) { | ||
if (channel.status === STATUS.DONE) { | ||
channel.getComponentList().forEach(function (component) { | ||
return component.onParentReady(); | ||
}); | ||
} | ||
}); | ||
} else { | ||
(function () { | ||
var doneChannelList = []; | ||
_this._component._channelManager.channels.forEach(function (channel) { | ||
if (channel.status === STATUS.DONE) { | ||
doneChannelList.push(channel); | ||
} | ||
}); | ||
_this._component._rootComponent.finish(doneChannelList); | ||
})(); | ||
} | ||
} | ||
this._onSendCallback(value, channelName); | ||
return this; | ||
} | ||
}, { | ||
key: "send", | ||
value: function send(value, channelName) { | ||
this.init(); | ||
this.prepare(value, channelName); | ||
this.done(); | ||
} | ||
}]); | ||
@@ -588,13 +638,2 @@ | ||
/***/ }, | ||
/* 9 */ | ||
/***/ function(module, exports) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var DEFAULT_CHANNEL = exports.DEFAULT_CHANNEL = "default"; | ||
/***/ }, | ||
/* 10 */ | ||
@@ -609,19 +648,53 @@ /***/ function(module, exports) { | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
/** | ||
* Request object which is passed to component onProcess method. | ||
* It contains calculated value from parent components channels | ||
*/ | ||
var Request = function () { | ||
function Request(value, source, target) { | ||
_classCallCheck(this, Request); | ||
var Request = function Request(valueList) { | ||
_classCallCheck(this, Request); | ||
this._value = value; | ||
this._source = source; | ||
this._target = target; | ||
} | ||
this.value = []; | ||
this.value = valueList; | ||
}; | ||
_createClass(Request, [{ | ||
key: "getValue", | ||
value: function getValue() { | ||
return this._value; | ||
} | ||
}, { | ||
key: "getTarget", | ||
value: function getTarget() { | ||
return this._target; | ||
} | ||
}, { | ||
key: "getSource", | ||
value: function getSource() { | ||
return this._source; | ||
} | ||
}]); | ||
return Request; | ||
}(); | ||
exports.default = Request; | ||
/***/ }, | ||
/* 11 */ | ||
/***/ function(module, exports) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var ONE_JOINT_PER_CHANNEL_PAIR = exports.ONE_JOINT_PER_CHANNEL_PAIR = "two channels can have only one joint"; | ||
var NON_EXIST_CHANNEL = exports.NON_EXIST_CHANNEL = "channel do not exist"; | ||
var UNIQUE_NAME_CHANNEL = exports.UNIQUE_NAME_CHANNEL = "channel need unique name"; | ||
var UNIQUE_NAME_INPUT_CHANNEL = exports.UNIQUE_NAME_INPUT_CHANNEL = UNIQUE_NAME_CHANNEL; | ||
var UNIQUE_NAME_OUTPUT_CHANNEL = exports.UNIQUE_NAME_OUTPUT_CHANNEL = UNIQUE_NAME_CHANNEL; | ||
/***/ } | ||
/******/ ]); |
{ | ||
"name": "horpyna", | ||
"version": "0.8.0", | ||
"version": "0.9.0", | ||
"description": "utility to manage async processes", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "./node_modules/.bin/mocha --compilers js:babel-register --check-leaks --timeout 3000 tests", | ||
"test": "./node_modules/.bin/mocha --require source-map-support --require babel-register --check-leaks --timeout 3000 tests/*", | ||
"build": "webpack --config webpack.config.js" | ||
@@ -22,3 +22,5 @@ }, | ||
"conditional", | ||
"organization" | ||
"organization", | ||
"typescript" | ||
], | ||
@@ -25,0 +27,0 @@ "author": "Krzysztof Sztompka <sztompka.krzysztof@gmail.com>", |
@@ -13,4 +13,4 @@ # HORPYNA | ||
* big amount async functions | ||
* some of them run only if some conditions meet | ||
* some of them run multiple times | ||
* some of them start only if some conditions meet | ||
* some of them start multiple times | ||
* you are bored of long promise chains with inner conditional sub chains | ||
@@ -56,3 +56,3 @@ * you want to reuse some parts of promise chains | ||
} | ||
onProcess(request, response) { | ||
onNext(request, response) { | ||
//input value is available from request.value | ||
@@ -64,3 +64,3 @@ //when component finish calculating response send it via response.send(componentResponse) | ||
export default CustomCOmponent1; | ||
export default CustomComponent1; | ||
@@ -74,3 +74,3 @@ YOU SHOULD BUILD COMPONENTS WITH OPTIONS WHICH SHOULD ALLOW YOUR COMPONENTS TO BE FLEXIBLE, | ||
onInit() { ... } | ||
onProcess(request, response) { ... } | ||
onNext(request, response) { ... } | ||
} | ||
@@ -82,3 +82,3 @@ | ||
onInit() { ... } | ||
onProcess(request, response) { ... } | ||
onNext(request, response) { ... } | ||
} | ||
@@ -107,19 +107,17 @@ | ||
let validateErrorMessageComponent = new SendResponse(options); | ||
validateErrorMessageComponent.bind(validateParamsComponent, "customErrorChannel"); | ||
validateParamsComponent.addJoint(validateErrorMessageComponent, "customErrorChannel"); | ||
let getUserList = new GetEntityFromDb(options); | ||
getUserList.bind(validateParamsComponent); | ||
validateParamsComponent.addJoint(getUserList); | ||
let zeroUsersErrorMessageComponent = new SendResponse(options); | ||
zeroUsersErrorMessageComponent.bind(getUserList, "otherCustomErrorChannel"); | ||
getUserList.addJoint(zeroUsersErrorMessageComponent, "otherCustomErrorChannel"); | ||
let calculateWhenOneEntity = new CalculateSomething(options); | ||
calculateWhenOneEntity.bind(getUserList, "oneEntityChannel"); | ||
calculateWhenOneEntity.final(); | ||
getUserList.addJoint(calculateWhenOneEntity, "oneEntityChannel"); | ||
let calculateWhenManyEntities = new CalculateSomething(options); | ||
calculateWhenManyEntities.bind(getUserList, "manyEntitiesChannel"); | ||
calculateWhenManyEntities.final(); | ||
getUserList.addJoint(calculateWhenManyEntities, "manyEntitiesChannel"); | ||
validateParamsComponent.run(startParameters, output => { | ||
validateParamsComponent.start(startParameters, outputChannel => { | ||
//callback when chain finished calculation | ||
@@ -138,46 +136,2 @@ }); | ||
### Component | ||
#### constructor(options) | ||
#### onInit(options) | ||
#### onProcess(request:Request, response:Response) | ||
#### run(value, endCallback) | ||
#### onParentReady() | ||
#### getChannel(channelName):Channel | ||
#### createChannel(channelName) | ||
#### final() | ||
#### bind(component:Component, channelName) | ||
### Channel | ||
#### constructor(component, name) | ||
#### addComponent(component) | ||
#### getComponentList() | ||
### Request | ||
#### constructor(value) | ||
### Response | ||
#### constructor(component) | ||
#### init() | ||
#### prepare(value, channelName) | ||
#### done() | ||
#### send(value, channelName) | ||
## DEVELOPMENT | ||
@@ -188,7 +142,3 @@ | ||
If you wish to help with this module, below there are instructions. | ||
Run dev build and watch on files changes: | ||
npm run dev | ||
Run production build: | ||
@@ -195,0 +145,0 @@ |
@@ -1,28 +0,16 @@ | ||
import * as STATUS from "../constants/statuses"; | ||
import Component from "./component"; | ||
import ChannelManager from "./channelManager"; | ||
class Channel { | ||
component: Component; | ||
name: string; | ||
status: string; | ||
connectedChildrenComponents: Component[]; | ||
value: any; | ||
class Channel extends ChannelManager{ | ||
private _name: string; | ||
constructor(component, name) { | ||
this.component = component; | ||
this.name = name; | ||
this.status = STATUS.INIT; | ||
this.connectedChildrenComponents = []; | ||
this.value = null; | ||
constructor(name: string) { | ||
super(); | ||
this._name = name; | ||
} | ||
addComponent(component) { | ||
this.connectedChildrenComponents.push(component); | ||
getName(): string { | ||
return this._name; | ||
} | ||
getComponentList() { | ||
return this.connectedChildrenComponents; | ||
} | ||
} | ||
export default Channel; |
import Channel from "./channel"; | ||
import Component from "./component"; | ||
class ChannelManager { | ||
component: Component; | ||
channels: Channel[]; | ||
constructor(component) { | ||
this.component = component; | ||
this.channels = []; | ||
private _channels: Channel[]; | ||
constructor() { | ||
this._channels = []; | ||
} | ||
createChannel(name) { | ||
this.channels.push(new Channel(this.component, name)); | ||
public isChannelByName(channelName: string): boolean { | ||
return typeof this.getChannel(channelName) !== "undefined"; | ||
} | ||
getChannel(name) { | ||
return this.channels.find(channel => channel.name === name); | ||
public isChannel(testChannel: Channel): boolean { | ||
return this.getChannels().some(channel => channel === testChannel); | ||
} | ||
public addChannel(channel: Channel): void { | ||
this._channels.push(channel); | ||
} | ||
public getChannel(name: string): Channel { | ||
return this._channels.find(channel => channel.getName() === name); | ||
} | ||
public getChannels(): Channel[] { | ||
return this._channels; | ||
} | ||
} | ||
export default ChannelManager; |
@@ -1,110 +0,112 @@ | ||
import Root from "./root"; | ||
import ChannelManager from "./channelManager"; | ||
import ParentChannelManager from "./parentChannelManager"; | ||
import IResponseCallback from "./iResponseCallback"; | ||
import Channel from "./channel"; | ||
import InputChannel from "./inputChannel"; | ||
import CallbackChannel from "./callbackChannel"; | ||
import OutputChannel from "./outputChannel"; | ||
import IInputSetValueCallback from "./iInputSetValueCallback"; | ||
import ICallbackSetValueCallback from "./iCallbackSetValueCallback"; | ||
import Response from "./response"; | ||
import Request from "./request"; | ||
//import Channel from "./channel"; | ||
import * as STATUS from "../constants/statuses"; | ||
import * as CHANNEL from "../constants/channels"; | ||
import * as ERROR from "../constants/errors"; | ||
class Component { | ||
_parentChannelManager: ParentChannelManager; | ||
_channelManager: ChannelManager; | ||
_status: string; | ||
_finalComponentFlag: boolean; | ||
_rootComponent: Root; | ||
private _inputChannelManager: ChannelManager; | ||
private _outputChannelManager: ChannelManager; | ||
constructor(options) { | ||
this._parentChannelManager = new ParentChannelManager(); | ||
this._channelManager = new ChannelManager(this); | ||
this._channelManager.createChannel(CHANNEL.DEFAULT_CHANNEL); | ||
this._status = STATUS.INIT; | ||
this._finalComponentFlag = false; | ||
this._rootComponent = new Root(); | ||
this._rootComponent.addComponent(this); | ||
constructor(options:any) { | ||
this._inputChannelManager = new ChannelManager(); | ||
this._outputChannelManager = new ChannelManager(); | ||
this.createInputChannel(CHANNEL.DEFAULT_CHANNEL); | ||
this.createOutputChannel(CHANNEL.DEFAULT_CHANNEL); | ||
this.onInit(options); | ||
} | ||
/** | ||
* for override | ||
* It is for initialize component | ||
*/ | ||
onInit(options) {} | ||
public onInit(options:any) {} | ||
onProcess(request, response) { | ||
response.send(request.value); | ||
public onNext(request: Request, response: Response) { | ||
response.send(request.getValue()); | ||
} | ||
/** | ||
* triggered once from root component. It start all process. | ||
* It need to have connection ready. | ||
* @returns Promise promise is resolved when every component in tree is done. | ||
*/ | ||
run(value, endCallback) { | ||
this._rootComponent.run(endCallback); | ||
this._runProcess([value]); | ||
public start(value:any, targetChannelName: string = CHANNEL.DEFAULT_CHANNEL): Component { | ||
return this.next(new Request(value, null, this.getInputChannel(targetChannelName))); | ||
} | ||
/** | ||
* Start to run component logic from this.onProcess. | ||
*/ | ||
_runProcess(parentResponseValueList) { | ||
this._status = STATUS.PROCESS; | ||
setTimeout(() => this.onProcess(new Request(parentResponseValueList), new Response(this)), 0); | ||
public next(request: Request): Component { | ||
let response: Response = new Response(this._getResponseCallback()); | ||
setTimeout(() => this.onNext(request, response), 0); | ||
return this; | ||
} | ||
/** | ||
* When parent component is done, it inform his child components about it. Which allow them to start | ||
* By default child component start when all parent components are done. | ||
*/ | ||
onParentReady() { | ||
if (this._parentChannelManager.isDone()) { | ||
this._runProcess(this._parentChannelManager.getChannelsValue()); | ||
public addJoint(target: Component, currentChannelName: string = CHANNEL.DEFAULT_CHANNEL, targetChannelName: string = CHANNEL.DEFAULT_CHANNEL): Component { | ||
let targetInput: Channel = target.getInputChannel(targetChannelName); | ||
let currentOutput: Channel = this.getOutputChannel(currentChannelName); | ||
if(targetInput.isChannel(currentOutput) === false && currentOutput.isChannel(targetInput) === false) { | ||
targetInput.addChannel(currentOutput); | ||
currentOutput.addChannel(targetInput); | ||
} else { | ||
throw Error(ERROR.ONE_JOINT_PER_CHANNEL_PAIR); | ||
} | ||
return this; | ||
} | ||
getChannel(channelName) { | ||
return this._channelManager.getChannel(channelName); | ||
public addCallback(target: ICallbackSetValueCallback, currentChannelName: string = CHANNEL.DEFAULT_CHANNEL) { | ||
let currentOutput: Channel = this.getOutputChannel(currentChannelName); | ||
currentOutput.addChannel(new CallbackChannel(target)); | ||
return this; | ||
} | ||
createChannel(channelName) { | ||
this._channelManager.createChannel(channelName); | ||
private _getResponseCallback(): IResponseCallback { | ||
return (value: any, channelName: string) => { | ||
this.getOutputChannel(channelName).emitValue(value); | ||
}; | ||
} | ||
/** | ||
* If this method is triggered before component is done, it is flagged as final component, | ||
* this means that when it is done also component chain is done | ||
*/ | ||
final() { | ||
this._finalComponentFlag = true; | ||
return this; | ||
public isInputChannel(channelName: string = CHANNEL.DEFAULT_CHANNEL): boolean { | ||
return this._inputChannelManager.isChannelByName(channelName); | ||
} | ||
/** | ||
* bind parent component with this component | ||
* @param component parent component | ||
* @param channelName parent channel name | ||
*/ | ||
bind(parent: Component, channelName: string) { | ||
channelName = channelName || CHANNEL.DEFAULT_CHANNEL; | ||
let parentChannel = parent.getChannel(channelName); | ||
this._parentChannelManager.addChannel(parentChannel); | ||
parentChannel.addComponent(this); | ||
parent.setChildRootComponent(this, this._rootComponent); | ||
public isOutputChannel(channelName: string = CHANNEL.DEFAULT_CHANNEL): boolean { | ||
return this._outputChannelManager.isChannelByName(channelName); | ||
} | ||
setChildRootComponent(child: Component, root: Root) { | ||
this._rootComponent.merge(root); | ||
child.setRootComponent(this._rootComponent); | ||
public getInputChannel(channelName: string = CHANNEL.DEFAULT_CHANNEL): InputChannel { | ||
if(this.isInputChannel(channelName) === false) { | ||
throw Error(ERROR.NON_EXIST_CHANNEL); | ||
} | ||
return <InputChannel> this._inputChannelManager.getChannel(channelName); | ||
} | ||
setRootComponent(root: Root) { | ||
this._rootComponent = root; | ||
public getOutputChannel(channelName: string = CHANNEL.DEFAULT_CHANNEL): OutputChannel { | ||
if(this.isOutputChannel(channelName) === false) { | ||
throw Error(ERROR.NON_EXIST_CHANNEL); | ||
} | ||
return <OutputChannel> this._outputChannelManager.getChannel(channelName); | ||
} | ||
getStatus() { | ||
return this._status; | ||
public _getInputChannelSetValueCallback(): IInputSetValueCallback { | ||
return (value: any, sourceOutput: OutputChannel, currentInput: InputChannel) => { | ||
this.next(new Request(value, sourceOutput, currentInput)); | ||
}; | ||
} | ||
public createInputChannel(channelName: string): Component { | ||
if(this.isInputChannel(channelName) === true) { | ||
throw Error(ERROR.UNIQUE_NAME_INPUT_CHANNEL); | ||
} | ||
this._inputChannelManager.addChannel(new InputChannel(channelName, this._getInputChannelSetValueCallback())); | ||
return this; | ||
} | ||
public createOutputChannel(channelName: string): Component { | ||
if(this.isOutputChannel(channelName) === true) { | ||
throw Error(ERROR.UNIQUE_NAME_OUTPUT_CHANNEL); | ||
} | ||
this._outputChannelManager.addChannel(new OutputChannel(channelName)); | ||
return this; | ||
} | ||
} | ||
export default Component; |
@@ -1,13 +0,28 @@ | ||
/** | ||
* Request object which is passed to component onProcess method. | ||
* It contains calculated value from parent components channels | ||
*/ | ||
import OutputChannel from "./outputChannel"; | ||
import InputChannel from "./inputChannel"; | ||
class Request { | ||
public value = []; | ||
private _value: any; | ||
private _source: OutputChannel; | ||
private _target: InputChannel; | ||
constructor(valueList) { | ||
this.value = valueList; | ||
constructor(value:any, source: OutputChannel, target: InputChannel) { | ||
this._value = value; | ||
this._source = source; | ||
this._target = target; | ||
} | ||
public getValue(): any { | ||
return this._value; | ||
} | ||
public getTarget(): InputChannel { | ||
return this._target; | ||
} | ||
public getSource(): OutputChannel { | ||
return this._source; | ||
} | ||
} | ||
export default Request; |
@@ -1,60 +0,19 @@ | ||
import * as STATUS from "../constants/statuses"; | ||
import * as CHANNEL from "../constants/channels"; | ||
import Component from "./component"; | ||
import Channel from "./channel"; | ||
/** | ||
* Object which is passed to component onProcess method. | ||
* It allow to set responses to channels of components and then pass it to child components in Request | ||
*/ | ||
import IResponseCallback from "./iResponseCallback"; | ||
class Response { | ||
private _component: Component; | ||
constructor(component: Component) { | ||
this._component = component; | ||
} | ||
private _onSendCallback: IResponseCallback; | ||
init() { | ||
this._component._channelManager.channels.forEach((channel:Channel) => { | ||
channel.status = STATUS.INIT; | ||
channel.value = null; | ||
}); | ||
constructor(onSendCallback: IResponseCallback) { | ||
this._onSendCallback = onSendCallback; | ||
} | ||
prepare(value, channelName) { | ||
if(this._component._rootComponent._status === STATUS.PROCESS) { | ||
channelName = channelName || CHANNEL.DEFAULT_CHANNEL; | ||
let channel: Channel = this._component.getChannel(channelName); | ||
channel.status = STATUS.DONE; | ||
channel.value = value; | ||
} | ||
} | ||
done() { | ||
if(this._component._rootComponent._status === STATUS.PROCESS) { | ||
this._component._status = STATUS.DONE; | ||
if (this._component._finalComponentFlag === false) { | ||
this._component._channelManager.channels.forEach(channel => { | ||
if (channel.status === STATUS.DONE) { | ||
channel.getComponentList().forEach(component => component.onParentReady()); | ||
} | ||
}); | ||
} else { | ||
let doneChannelList = []; | ||
this._component._channelManager.channels.forEach(channel => { | ||
if (channel.status === STATUS.DONE) { | ||
doneChannelList.push(channel); | ||
} | ||
}); | ||
this._component._rootComponent.finish(doneChannelList); | ||
} | ||
} | ||
send(value: any = undefined, channelName: string = CHANNEL.DEFAULT_CHANNEL): Response { | ||
this._onSendCallback(value, channelName); | ||
return this; | ||
} | ||
send(value, channelName) { | ||
this.init(); | ||
this.prepare(value, channelName); | ||
this.done(); | ||
} | ||
} | ||
export default Response; |
import Component from "./components/component"; | ||
import Channel from "./components/channel"; | ||
import InputChannel from "./components/inputChannel"; | ||
import OutputChannel from "./components/outputChannel"; | ||
import ChannelManager from "./components/channelManager"; | ||
import Request from "./components/request"; | ||
import Response from "./components/response"; | ||
import * as CHANNEL from "./constants/channels"; | ||
export default { | ||
Component | ||
Component, | ||
Channel, | ||
InputChannel, | ||
OutputChannel, | ||
ChannelManager, | ||
Request, | ||
Response, | ||
CHANNEL | ||
}; |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
107829
43
1171
157
1