Using transducers with RxJS

In the last section, we learned how we can apply a transducer to the most simple iterable object in JavaScript, an array. But we are more interested in how we can use this tool in functional reactive programming using RxJS.

Using transducers with RxJS we can see performance improvements, as we will avoid the creation of intermediate observable sequences and can improve the overall quality of our code with the composition of transformations.

To use a transducer in RxJS we need to use the transduce operator of the RxJS library; this operator has the following signature:

observable.transduce(transducer) 

It receives only one mandatory argument:

  • transducer: It is the transducer transformation to be applied on the ...

Get Mastering Reactive JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.