Future[Option] in Scala for-comprehensions

前端 未结 5 1671
闹比i
闹比i 2020-12-07 19:16

I have two functions which return Futures. I\'m trying to feed a modified result from first function into the other using a for-yield comprehension.

This approach w

5条回答
  •  一个人的身影
    2020-12-07 19:38

    We've made small wrapper on Future[Option[T]] which acts like one monad (nobody even checked none of monad laws, but there is map, flatMap, foreach, filter and so on) - MaybeLater. It behaves much more than an async option.

    There are a lot of smelly code there, but maybe it will be usefull at least as an example. BTW: there are a lot of open questions(here for ex.)

提交回复
热议问题