O'Reilly logo

Mastering Reactive JavaScript by Erich de Souza Oliveira

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using transducers

As we discussed in previous sections, transducers are a way to compose algorithmic transformations over iterable objects; to see this in action, let's first use a transducer in the most simple iterable object, an array.

To run a transducer over an array we first need a method to run a given transformation in a given iterable object.

For this we use the into() method, which has the following signature:

transducers.into(emptyIterable,transformation,iterable) 

It receives three parameters and they are all mandatory:

  • emptyIterable: It is an empty iterable used to store the result of the application of the transformation over the iterable object
  • transformation: It is the function or transducers to be applied over the iterable ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required