Skip to main content

pipeObservable

Alternative: pipe$$

Types

function pipeObservable<
GObservable extends IGenericObservable,
GFunctions extends IObservablePipeConstraint<GObservable, GFunctions>
>(
subscribe: GObservable,
fns: GFunctions,
): IObservablePipeReturn<GObservable, GFunctions>

Definition

This function allows you to pipe (chain) an Observable with many ObservablePipes.

This is equivalent the RxJS Observable.pipe method.

Example

ObservablePipe which keeps only positive numbers and convert them to strings

const subscribe = pipe$$(of(-2, -1, 0, 1, 2), [
filter$$$(value => (value >= 0)),
map$$$(String),
]);

const unsubscribe = subscribe((value: string) => {
console.log(value);
});

Output:

0
1
2
RxJS equivalent
of(-2, -1, 0, 1, 2)
.pipe(
filter(value => (value >= 0)),
map(String),
)
.subscribe((value: string) => {
console.log(value);
});