-
Notifications
You must be signed in to change notification settings - Fork 30
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
Add Source.mapStateful and Source.mapStatefulConcat combinators #15
Conversation
Also, any ideas for more test cases are welcome 😄 |
I think that the akka streams approach might make sense - a general |
See #18 (comment) for a discussion about checking |
false | ||
case ChannelClosed.Error(r) => | ||
c.error(r) | ||
false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think here we already have the desired error handling, so no changes should be necessary :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're still checking the result of c.send
below in result.iterator.map(c.send).forall(_.isValue)
, although we assume that send
should not fail since we control c
, so we should probably always return true
after sending, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, though this at worst is dead code - not that there's a possiblity of incorrect behavior. We can change this though:
- ignoring the return value probably needs a comment that we know what we are doing - and why
- in larger code chunks (which are harder to follow), we might opt for the defensive solution anyway
I'm not sure whether
f
should return(S, Option[U])
or(S, U)
- where in the former case theOption
indicates whether anything should be sent downstream.The former is more flexible, but introduces additional complexity to the signature. Comparing to Akka Streams, the current approach mixes
statefulMap
andstatefulMapConcat
a bit, in that you can control whether the result off
will be sent downstream at all. However, unlike in Akka Streams,f
can only return anOption
, not anIterable
(which is flattened in Akka'sstatefulMapConcat
).Any thoughts on this (or anything else in the proposed approach)?