Add the Transducer Protocol to Support Arbitrary Data Types as our Target Collections

Paul Frend
InstructorPaul Frend

Share this video with your friends

Send Tweet

Our helpers are now powerful enough to work with any data type as the source, but they can only build up arrays or objects as the target. For an arbitrary collection type, we thus have to fall back to our transduce function and manually specify the inner reducer behavior based on the API of our target collection.

In this lesson, we'll add support for the transducer protocol, and see how it enables us to transduce into any collection type without having to fall back to using transduce. We'll use the List type from Immutable.JS as our example.