Scala ZIOStream with Future

126 views Asked by At

I'm trying to compose ZIO.fromFuture with ZStream.async following this example but I have a type issue: ZIO.fromFuture gives me Task[+A] = ZIO[Any, Throwable, A] but Zstream.emit needs ZIO[R, Option[E], Chunk[A]]

[Option[Throwable] vs Throwable2

How could I turn a Future into a ZStream if that makes sense?

    val t: ZIO[Any, Throwable, Chunk[A]] = ZIO.fromFuture(_ => Future[A])
    val stream = ZStream.async[Any, Throwable, A] { cb =>
      cb(t)
      None
    }
0

There are 0 answers