【发布时间】:2022-01-22 17:47:21
【问题描述】:
我关注this。我的程序结构是:
(for {
data <- myService.fetch(id).eitherT
values <- anotherService.fetch(data.id).eitherT
// todo: process values as part of forcomprehension
} yield data.id).value
myService.fetch 返回 Future[...]。
anotherService.fetch 也返回 Future[...],values 是一个 Seq。 我想使用 foreach 处理值中的条目
values.foreach(value => service.moreAction(value))
moreAction 也返回 Future[...]
因此,我的目标是将它与以前的 Futures 链接起来以供理解。
什么是惯用的做法?
【问题讨论】:
标签: scala scala-cats