在mosby-mvi中,处理导航到的活动返回的数据的正确方法是什么?

时间:2019-01-09 03:39:26

标签: mosby

在mosby-mvi中,正确处理从startActivityForResult调用的活动返回的结果数据的正确方法是什么?

就我而言,意图在onActivityResult中触发,但mapRefreshSingle()从未触发。

活动代码:

val refreshSingleIntent: Subject<Int> = PublishSubject.create()

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    super.onActivityResult(requestCode, resultCode, data)
    if ((requestCode == REQUEST_UPDATE_EMPLOYEE) && resultCode == Activity.RESULT_OK)
        refreshSingleIntent.onNext(data?.extras?.getInt("emid") ?: 0)
}

演示者代码

override fun bindIntents() {
    intent(EmployeesView::refreshSingleIntent).mapRefreshSingle(baseContext)
    subscribeViewState(...)
}

fun Observable<Int>.mapRefreshSingle(baseContext: Context): Observable<PartialViewState> = 
    flatMap { emid ->
        //code never reached ...
    }

0 个答案:

没有答案