@connectv/core
Version:
agent-based reactive programming library for typescript/javascript
65 lines • 2.25 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 (b.hasOwnProperty(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 });
var rxjs_1 = require("rxjs");
var pin_1 = require("./pin");
/**
*
* Represents [pipe](https://connective.dev/docs/pipe) pins.
*
*/
var Pipe = /** @class */ (function (_super) {
__extends(Pipe, _super);
function Pipe(pipes) {
var _this = _super.call(this) || this;
_this.pipes = pipes;
return _this;
}
/**
*
* Resolves the underling observable of the pin, by
* [mergeing](https://rxjs-dev.firebaseapp.com/api/index/function/merge)
* observables of inbound pins and piping them through specified
* [pipeable operators](https://github.com/ReactiveX/rxjs/blob/master/doc/pipeable-operators.md).
*
* @param inbound
*
*/
Pipe.prototype.resolve = function (inbound) {
return this.pipes.reduce(function (observable, pipe) { return observable.pipe(pipe); }, (inbound.length == 1) ?
inbound[0].observable : rxjs_1.merge.apply(void 0, inbound.map(function (pin) { return pin.observable; })));
};
return Pipe;
}(pin_1.Pin));
exports.Pipe = Pipe;
/**
*
* Creates a [pipe](https://connective.dev/docs/pipe) pin using given pipe functions.
* You can utilize this to use RxJS's pipeable operators in CONNECTIVE flows.
* [Checkout the docs](https://connective.dev/docs/pipe) for examples and further information.
*
* @param pipes
*
*/
function pipe() {
var pipes = [];
for (var _i = 0; _i < arguments.length; _i++) {
pipes[_i] = arguments[_i];
}
return new Pipe(pipes);
}
exports.pipe = pipe;
exports.default = pipe;
//# sourceMappingURL=pipe.js.map