答案 0 :(得分:4)
RxJava中的大多数静态函数都是RxKotlin中的扩展函数。此特定功能是function postLogin(Request $request){
return response() -> json(['url' => '/login-ok',], 200);
}
的扩展。你可以这样称呼它:
Iterable<Observable<T>>
答案 1 :(得分:2)
对于RxJava 2,可以通过这种方式完成
val list = Arrays.asList(
remoteRepository.getHospitals(),
remoteRepository.getQuestionCategories(),
remoteRepository.getQuestions(),
)
return Observable.combineLatest(list) {
val hospitals = it[0] as List<Hospital>
val questionCategories = it[1] as List<QuestionCategory>
val questions = it[2] as List<Question>
localRepository.insertHospitals(hospitals)
localRepository.insertQuestionCategories(questionCategories)
localRepository.insertQuestions(questions)
if (hospitals.isNotEmpty())
Constants.STATUS_OK
else
Constants.STATUS_ERROR
}
答案 2 :(得分:0)
val list = Arrays.asList(Observable.just(1), Observable.just("2"))
Observable.combineLatest(list, object : FuncN<String>() {
fun call(vararg args: Any): String {
var concat = ""
for (value in args) {
if (value is Int) {
concat += value
} else if (value is String) {
concat += value
}
}
return concat
}
})
Observable.just(1),Observable.just(&#34; 2&#34;)可以替换为observable列表,登录内部调用fun也会根据需要改变。