在onSuccess之前完成Single.zip

时间:2017-11-15 23:01:01

标签: kotlin rx-java2

我想在一个对象中结合2个单曲的响应

override fun buildUseCase(params: Int): Single<EventDetails> {
    return eventDetailsComponent.getEventDetails(params)
        .zipWith(bookingComponent.getBookingPage(bookingParams), BiFunction { details, page ->
              return@BiFunction details.apply { booking_page = page } })
}

但是当我订阅时我没有收到onSuccess,因为其中一个单曲在另一个之前完成

fun loadEventDetails(id: Int) {
 usecase.execute(id)
.doOnSubscribe(onSubscribe)
.observeOn(SchedulerProvider.mainThread)
.subscribeBy(onSuccess = { details -> setValues(details) },onError = onError)
.addTo(subscriptions)
}

如何合并这些来电?或者到底收到onSuccess?

1 个答案:

答案 0 :(得分:0)

显然我忘记了XPathExpression.evalute(Object item)主线程