Tag: rx kotlin2

如何使用RxJava2 combineLatest与Kotlin中的可观察列表

我知道如何在RxJava 2中做到这一点 。 而且我知道RxKotlin如何帮助解决类似的问题。 但似乎RxKotlin.Observables没有这个帮助函数的列表超载,我无法弄清楚。 你会怎么做?

rxkotlin groupby不工作

你能帮我按照下面的json分组,并根据与RxKotlin的日期在kotlin中返回一个hashMap吗? 对于kotlin来说非常简单,但对于Rxkotlin来说真的很困难。 谢谢 val groupedTransactions = accountTransactions.transactions?.groupBy {it.effectiveDate} “transactions”: [{ “id”: “44e5b2bc484331ea24afd85ecfb212c8”, “effectiveDate”: “20/07/2017”, “description”: “Kaching TFR from JOHN CITIZENxmas donation”, “amount”: 12.00 }, { “id”: “1506aeeb8c3a699b1e3c87db03156428”, “effectiveDate”: “20/07/2017”, “description”: “Wdl ATM CBA ATM CIRCULAR QUAY STATION NSW 221092 AUS”, “amount”: -200.00, “atmId”: “129382” }, { “id”: “9a899bfd978511e9605774e1d5222b67”, “description”: “Savings”, “effectiveDate”: “19/07/2017”, “amount”: 10.00 }, […]

RxJava2:onComplete不用flatMapIterable调用

这是简短的代码片段: val subject = BehaviorSubject.createDefault(emptyList<Int>()) subject.onNext(Arrays.asList(1, 2, 3)) subject.flatMapIterable { list: List<Int> -> list } .subscribeBy( onNext = { l("on next", it) }, onComplete = { l("on complete") } ) 为什么onComplete不会在这里打电话? 我应该怎么做这个代码? 因为在原始代码中我不能使用.toList()方法。

在条件符合的情况下更改可观察 – RxJava2

使用RxJava2 RxKotlin和Room ,我需要查询数据库中的一个开放的狩猎。 这意味着我搜索一个包含一个名为closed的值为false的属性。 一旦找到猎物,就需要将查询切换到特定的猎物。 对于这些查询我有2个方法: getOpenHunt(teamId:String): Flowable<List<Hunt>> getHunt(huntId:String): Flowable<List<Hunt>> 他们都返回一个List因为否则查询卡住没有找到狩猎时。 我的想法是类似的 fun queryHunt(teamId:String):Flowable<Optional<Hunt>>{ getOpenHunt(teamId) .map<Optional<Hunt>> { Optional.create(it.firstOrNull()) } .switchToFlowableIf ( it is Optional.Some, getHunt(it.element().id) } //With switchToFlowableIf's being fun <E:Any> switchToFlowableIf(condition: (E)->Boolean, newFlowable: Flowable<E>): Flowable<E> //It should unsubscribe from getOpenHunt and subscribe to newFlowable 作为参考,这里是我的Optional类 sealed class Optional<out T> { class Some<out T>(val element: […]

如何在RxJava2中默默跳过异常?

我有这样的数据流: Observable .fromFuture( CompletableFuture.supplyAsync { // First remote call returns Future<List<Type>> listOf(1, 2, 3, 57005, 5) }, Schedulers.computation() ) .flatMap { it.toObservable() } // I turn that list into a stream of single values to process them one by one .map { CompletableFuture.supplyAsync { // This remote call may fail if it does not like […]