Observable pipe arguments that are "falsy" are skipped #6244
Replies: 4 comments 12 replies
-
Seems like a great idea to me. A false/falsy value now in a |
Beta Was this translation helpful? Give feedback.
-
One thing I just thought of though... Typing this would be nearly impossible. 😿 We already have 9-10 overloads for pipe just to handle what it handles. This would require nearly n^n overloads to work with the same number of arguments, I think. cc @cartant. |
Beta Was this translation helpful? Give feedback.
-
I believe that it should be added to the concat as well. |
Beta Was this translation helpful? Give feedback.
-
Core team meeting: This might be better as an educational thing about how to use ternaries to accomplish this. Maybe we even consider an operator that just returns identity to help readability? Still up for debate. The typings complexity around the original proposal is way too high to implement, and the proposed |
Beta Was this translation helpful? Give feedback.
-
So often I find myself doing this pattern when I want to conditionally apply an operator:
Or I end up rolling a helper so I can do this:
It would be great if this:
source$.pipe(operator1, null, operator2)
was the same assource$.pipe(operator1, operator2)
.So I would propose a new feature (which would be non-breaking) where any "falsy" value that is passed to
Observable.prototype.pipe
is ignored/skipped. Which would make the above:Beta Was this translation helpful? Give feedback.
All reactions