-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request: Overloaded version of .alsoTo that takes a function #28524
Comments
I don't think we should add that. For the actor use case, if that message interaction is not ask with a reply that arrives in the stream you won't know that it was delivered and it will not slow the stream down if the actor cannot keep up, but instead fill the mailbox and potentially the heap. I don't think fire-and-forget-without backpressure is something we should encourage even if it can make sense in some use cases. If the operation should delay the stream element and you do not want to fan out for some reason I think Note that if this is something you need very often in a specific project you should be able to add your own operators to the stream factories through implicit decoration/extension methods. |
Thanks for getting back to me.
Thanks, I may do that. Just for reference, the question of syntax and sensibility has been discussed along the same lines in #23512. My concern is that the current implementation for that issue (
Sending a message to an actor was an example use-case, but it could be any side-effect that does not need back-pressure. Having said that: In the above example back-pressure is already generated by the Just adding my two cents. I'm coming from the same position as the original issue's author, having run into a need for this operator a few times. |
Having just come across this again, I also think that there's still utility in having a |
It would be nice for
.alsoTo
, the back-pressuring version of.wireTap
, to accept aT => Unit
additionally to the currentSink
signature for readable execution of element-wise side effects..wireTap
already provides both signatures.Context:
.wireTap
was added for execution of side-effects in a Flow without transforming the elements (see #23512). The issue is that it drops elements when the side-effect back-pressures, which makes it unsuitable in situations where the side-effect is an essential part of the stream processing.If
.alsoTo
is not a suitable operator name for this overload, my suggestion is.sideEffect
. An example use case would be telling an actor that an element has been processed (and can be removed from the persisted stack or similar):Relevant historic PR: #24610 (
.wireTap
)The text was updated successfully, but these errors were encountered: