@connectv/core
Version:
agent-based reactive programming library for typescript/javascript
40 lines • 1.24 kB
JavaScript
import { merge } from 'rxjs';
import { Pin } from './pin';
/**
*
* Represents [pipe](https://connective.dev/docs/pipe) pins.
*
*/
export class Pipe extends Pin {
constructor(pipes) {
super();
this.pipes = pipes;
}
/**
*
* 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
*
*/
resolve(inbound) {
return this.pipes.reduce((observable, pipe) => observable.pipe(pipe), (inbound.length == 1) ?
inbound[0].observable :
merge(...inbound.map(pin => pin.observable)));
}
}
/**
*
* 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
*
*/
export function pipe(...pipes) { return new Pipe(pipes); }
export default pipe;
//# sourceMappingURL=pipe.js.map