softshipper
softshipper

Reputation: 34061

How to create materialize value with the source?

I am trying to create the materialize value, when I create a source as the following:

case class Info(value: String)
val source: Source[String, Future[Info]] = Source.single("Start")

But it does not work. How to create a source with materialize value?

Upvotes: 2

Views: 107

Answers (1)

Dmytro Mitin
Dmytro Mitin

Reputation: 51648

Can you use mapMaterializedValue?

val source: Source[String, Future[Info]] = Source.single("Start")
  .mapMaterializedValue(_ => Future(Info("abc")))

Upvotes: 5

Related Questions