Member-only story

RxJS: Pipelining Lettable Operators

Nicholas Jamieson
2 min readSep 29, 2017

--

Photo by David Rangel on Unsplash

Earlier this week, a TC39 proposal for a pipeline operator moved to stage-1. If the proposal is eventually accepted and included in the ECMAScript standard — it has a long way to go — it will offer a new syntax for lettable operators.

What is proposed?

The proposed pipeline operator is |>. It’s a binary operator; the operand to its left is a value and the operand to its right is a function. The pipeline operator calls the function, passing the value as an argument, and returns the function’s result.

That is, 64 |> Math.sqrt is equivalent to Math.sqrt(64).

Using the pipeline operator, multiple functions can be pipelined, like this:

How would it be used with lettable operators?

The lettable operators introduced in the RxJS 5.5.0 beta are higher-order functions. They return functions that receive and return observables. As such, they can be used with the proposed pipeline operator, like this:

--

--

Nicholas Jamieson
Nicholas Jamieson

Written by Nicholas Jamieson

RxJS core team member; front-end developer; mentor; speaker; open-source contributor

Responses (2)