@rxx/core
Version:
React MVI micro framework.
44 lines (43 loc) • 2 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var advice_1 = require("./advice");
function combineAdvice() {
var _this = this;
var advices = [];
for (var _i = 0; _i < arguments.length; _i++) {
advices[_i] = arguments[_i];
}
function callAdvice(advice, mi, ih) {
return typeof advice !== 'function'
? advice.invoke(mi, ih)
: advice(mi, ih);
}
return function (mi, ih) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
var loop, clone;
var _this = this;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
loop = function (next, advices) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
var _this = this;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!next) return [3, 2];
return [4, callAdvice(next, new advice_1.MethodInvocation(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) {
return [2, loop(advices.shift(), advices)];
}); }); }, mi.getContext(), mi.getArguments(), mi.getInstanceName(), mi.getPropertyName()), ih)];
case 1: return [2, _a.sent()];
case 2: return [2, mi.proceed()];
}
});
}); };
clone = advices.slice();
return [4, loop(clone.shift(), clone)];
case 1: return [2, _a.sent()];
}
});
}); };
}
exports.combineAdvice = combineAdvice;