Rx 和 Kotlin 中的泛型函数引用——类型推断失败
Generic Function References in Rx and Kotlin -- type inference failed
我正在用 Kotlin 写一个方法:
fun fetchDepositSession(): Completable =
Observable.fromIterable(session.accounts)
.map(DepositSession::DepositAccount)
.toList()
.doOnSuccess(depositSession::depositAccounts::set)
.flatMapObservable(Observable::fromIterable)
.map(DepositSession.DepositAccount::account::get)
.toCompletable()
第 .flatMapObservable(Observable::fromIterable)
行导致错误:
RxJava 和 Kotlin 推断类型效果不佳。有几个问题,例如 KT-13609 and KT-14984.
见 that is relative to the problem. There is also an issue in RxKotlin's Github说的
无论如何,你可以随时使用:
.flatMapObservable { Observable.fromIterable(it) }
我正在用 Kotlin 写一个方法:
fun fetchDepositSession(): Completable =
Observable.fromIterable(session.accounts)
.map(DepositSession::DepositAccount)
.toList()
.doOnSuccess(depositSession::depositAccounts::set)
.flatMapObservable(Observable::fromIterable)
.map(DepositSession.DepositAccount::account::get)
.toCompletable()
第 .flatMapObservable(Observable::fromIterable)
行导致错误:
RxJava 和 Kotlin 推断类型效果不佳。有几个问题,例如 KT-13609 and KT-14984.
见
无论如何,你可以随时使用:
.flatMapObservable { Observable.fromIterable(it) }