我正在处理下一个代码:
override fun get(context: SportListServiceContext): Single<Data> {
return sportListProvider.getPlayerBrowseSportsListId(context).map { playerBrowseSportsList ->
return@map playerBrowseSportsList
}.flatMap {
val list: List<Int> = listOf(it)
val dCSServiceContext = DCSServiceContext(list, ContentOrigin.ESPN, context.transaction)
return@flatMap sportListProvider.getSportList(dCSServiceContext)
}.map { navMenuItems ->
val presenterContext = SportListPresenterContext(SportsResponse(navMenuItems as NavMenu?), context.application, context.deepLinkType)
return@map sportListPresenter.present(presenterContext)
}
}
在这段代码中,我有一连串的依赖调用,但是不建议这样做,并且在要求中,这些调用不应是依赖的。
有什么想法可以实现这一目标的更复杂的方法吗?