Chain RxJS Operators Together with a Custom `pipe` Function using Array.reduce

InstructorJohn Lindquist

Share this video with your friends

Send Tweet

Instead of writing complex operators, it's usually best to write simple, single-purpose operators then chain them together when necessary. The pipe function takes functions as arguments, invokes each function with the value, then passes the returned result on to the next function.

J. Matthew
~ 5 years ago

It's hard for me to wrap my head around why it's not necessary to do the whole source.lift routine here. My best guess is that it's because we're replacing something (pipe) out of rxjs proper, rather than an operator. What we're passing into our custom pipe is always an operator and does have to follow that pattern, so presumably our "normal" JS here is just chaining the results of each of those source.lifts together.