Use Transducers in Production

Paul Frend
InstructorPaul Frend

Share this video with your friends

Send Tweet

While it’s possible to use our transducers in production (after writing some tests!), I would recommend using a proven transducer library instead.

In this lesson, we’ll go through how to use transducers.js from James Long instead of our functions. We’ll also cover some more advanced features which we didn't add support for ourselves, like short-circuiting iterations with the take transform as well as transducing lazily over iterables.

The aim is that you’ll be able to use these libraries with more confidence and better understanding since we’ve been through how things are working under the hood.

You can also check out transducers-js by cognitect labs, which is very similar in its feature set to transducers.js. And remember, you don’t have to rely solely on the transforms in the library, you can write your own as well, as long as you support the transducer protocol.

Bijoy Thomas
Bijoy Thomas
~ 3 years ago

Excellent course!

The short circuiting is awesome but somehow the types in the composition below seems a little odd.

doubleAndEven = t.compose(t.filter(isEven), t.map(double))

t.compose(doubleAndEven, t.take(2))

The doubleAndEven returned from the t.compose has transformations on numbers, which is then further composed with t.take which looks like a transformation on a list. I guess the way to look at it is that the type of t.whatever functions are reducers which can be composed