-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Description
这里面有段代码让我有点困惑,在HomeActionProcessorHolder这个类中,InitIntent 会触发 Paging 这个库的方法,比如从零加载和向下分页,
private val initialActionTransformer =
ObservableTransformer<HomeAction.InitialAction, HomeResult.InitialResult> { action ->
action.flatMap<HomeResult.InitialResult> {
repository.getReceivedPagedList(
boundaryCallback = object : PagedList.BoundaryCallback<ReceivedEvent>() {
override fun onZeroItemsLoaded() {
[email protected]()
}
override fun onItemAtEndLoaded(itemAtEnd: ReceivedEvent) {
[email protected](itemAtEnd)
}
}
).map(HomeResult::InitialResult).toObservable()
}
}
我注意到这两个方法会发出一个 PublishSubject<HomeResult.LoadingPageResult>,它会将:加载中、加载成功、加载失败 传递出去。如果这次请求成功的话,还会有一个 InitialResult 包括了请求成功返回的列表。
所以总结一下,InitialAction 会带来两种 Result,一个是 InitialAction 对应的 InitialResult,一个是 另外生成的 LoadingPageResult。我困惑的地方就在于,一种 Action 不应该只对应一种 Result 么。如果 一种 Action 可以对应多种 Result,感觉就没有一个单链条传递的关系了。
Metadata
Metadata
Assignees
Labels
No labels