He-Pin commented on code in PR #1787: URL: https://github.com/apache/pekko/pull/1787#discussion_r1984619549
########## stream/src/main/scala/org/apache/pekko/stream/scaladsl/Flow.scala: ########## @@ -2804,6 +2804,25 @@ trait FlowOps[+Out, +Mat] { def flattenMerge[T, M](breadth: Int)(implicit ev: Out <:< Graph[SourceShape[T], M]): Repr[T] = flatMapMerge(breadth, ev) + /** + * Transforms each input element into a `Source` of output elements that is + * then flattened into the output stream until a new input element is received + * at which point the current (now previous) substream is cancelled (which is why + * this operator is sometimes also called "flatMapLatest"). + * + * '''Emits when''' the current substream has an element available + * + * '''Backpressures when''' never + * + * '''Completes when''' upstream completes and the current substream completes + * + * '''Cancels when''' downstream cancels + * + * @since 1.2.0 + */ + def switchMap[T, M](f: Out => Graph[SourceShape[T], M]): Repr[T] = + map(f).via(new Switch[T, M].addAttributes(Attributes(SourceLocation.forLambda(f)))) Review Comment: You implemented it with a `map` and `switch` cool. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@pekko.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@pekko.apache.org For additional commands, e-mail: notifications-h...@pekko.apache.org