I'm reading through the documentation for Akka streams and I came across the mapConcat operator which is like the flatMap (at least on the conceptual level).
Here is a simple example:
scala> val src = Source.fromFuture(Future.successful(1 to 10))
src: akka.stream.scaladsl.Source[scala.collection.immutable.Range.Inclusive,akka.NotUsed] = Source(SourceShape(FutureSource.out(51943878)))
I was expecting that type of the Source is rather:
akka.stream.scaladsl.Source[Future[scala.collection.immutable.Range.Inclusive],akka.NotUsed]
Why is that not the case?
My understanding of the types for each line is as shown below:
Source
.fromFuture(Future.successful(1 to 10)) // Source[Future[Int]]
.mapConcat(identity) // Source[Int]
.runForeach(println)
But the Source type in the example above is not what I thought it was!
Source.fromFutureor themapConcatoperator? - Stefano Bonetti