TapEach For Futures and Try #44
Labels
enhancement
New feature or request
library:concurrent
status:pending
This enhancement request lacks consensus on whether or not to include it
Reviving this old idea that we closed under scala/scala-dev#661.
Motivation
Currently
andThen
defined for Futures, doesn't preserve the error behavior. We could argue that if the side-effecting code throws an error, theFuture
is ought to fail, as @NthPortal previously pointed out, preserving the behavior inIterator
andLazyList
More consistent interface for all Monadic Product types (Option, List, all other Iterables etc.). If you want to do something like
Future|Option|Try .log(s"logging the value $_").map(...).log(...)
You either need to put
F|O|T.map(r => { log(....) r})
every where, which is rather ugly,Or you need to define extension methods on all them
with a consistent
tapEach
operation, you can do the following, which is much better IMOI have a draft PR for this, I will push that for everyone to see what this would look like.
Open to comments :)
The text was updated successfully, but these errors were encountered: