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 observable sequence
The transduce operator, like any other observable operator, returns a new operator, but as we can compose several transformations inside a single transducer...