DEV Community

Discussion on: I've used the pipe() function 2,560 times and I can tell you it's good!

 
ivan7237d profile image
Ivan Novikov

Oh I see - I talk a little bit about this function in the first section where I call it ltrCompose. It might well be a good option for folks who use fp-ts or Ramda, but personally I've moved away from it.

Thread Thread
 
dariomannu profile image
Dario Mannu

There is an equivalent pipe() function but for streams in RxJS: rxjs.dev/api/index/function/pipe (awful doc, don't read it)

Essentially, it enables you to do this:

const transformer = pipe(
  operator1(),
  operator2(),
  operatorN()
);

const stream = transformer(sourceObservable);
// ...
stream.subscribe(doSomething);
Enter fullscreen mode Exit fullscreen mode

Also, in Rimmel.js we created the reverse pipe, which is the same as above, except you use it to feed the input of an observer, rather than the output of an observable. We use it extensively to create event adapters for UI streams.

Whether any of this could be useful for stuff like the LazyPromise I'm not sure yet, just sharing for inspo