Questions tagged [rx-kotlin]

RxJava bindings for Kotlin programming language

RxKotlin is open sourced and available under the Apache License, Version 2.0

238 questions
1
vote
1 answer

How to implement robust offline support with rx-kotlin?

TL;DR Looking for recommendations on robust offline support using rx-kotlin. I've followed a nice guide on offline-support in Android apps. It works like this: Load data from the Internet, go to step 3 if error Store the data in the local…
Per Christian Henden
  • 1,514
  • 1
  • 16
  • 26
1
vote
1 answer

How to make this block of code written with RxKotlin cleaner and avoid blocking thread?

I have this function which gets a parameter and first checks for its value. if it was null then gets its value from the result of fisrtFun() which returns a Single< String>. after that either that parameter was null or not, it returns the result of…
1
vote
1 answer

How to pass value

How to get value time from this code val TAG = MainActivity::class.java.name TrueTimeRx.build() .initializeRx("time.google.com") .subscribeOn(Schedulers.io()) .subscribe({ time -> Log.v(TAG, "TrueTime was initialized and we…
1
vote
1 answer

RxJava: How to extract same observeOn from different functions?

Basically my Android app have some meta data which need to report to backend server in different scenarios: data class SearchMetaData( val searchId: String?, val isRateLimit: Boolean ) In order to make the code clean, I make the minimal…
alwaysday1
  • 1,683
  • 5
  • 20
  • 36
1
vote
3 answers

Perform a task for all items in a list and then perform another task in RxJava

Unfortunately, my REST Delete operation work only for one item. So what I was trying to do is, Observable.just(items).flatMapIterable { items -> items }.flatMap { //call REST DELETE for every item }.flatMap { …
sadat
  • 4,004
  • 2
  • 29
  • 49
1
vote
1 answer

RxKotlin combine latest more than 9 fields

I am new to Android development, I'm trying to make form validation using RxKotlin and RxBinding. I need a guidance how to make form validation with more than 9 fields? Actually I can combine the result using Observable.combinelatest. This is the…
1
vote
1 answer

RxKotlin "withLatestFrom(...)" compile error: not enough information to infer type variable R

1) The code below fails to compile with an error: "not enough information to infer type variable R" keywordChanges .withLatestFrom(searchParamsSubject) .subscribe { (keyword, searchParams) -> ... } 2) The code below compiles and works,…
Frank Harper
  • 3,027
  • 3
  • 30
  • 41
1
vote
1 answer

How to handle errors in rxjava chain in android?

I have a list of items say for example list of integers, if any of the integer is null, i need to consume the error and proceed with the next item For example Observable.fromIterable(listOf(1, 2, 3, null, 5)) .map { …
Stack
  • 1,164
  • 1
  • 13
  • 26
1
vote
1 answer

RxJava Collect emission to list

How can I collect emitted items from observable to List when observable never completes? Example I have something similar so Observable emits series of values, but never completes unless you unsubscribe, because of that .toList() not gonna…
LeTadas
  • 3,436
  • 9
  • 33
  • 65
1
vote
1 answer

When to subscribe/bind streams in android lifecycle?

I'm using rxAndroid with an MVVM architecture. In my Activity, I need to bind my streams then fetch data from the server, which will eventually call the downstream. My reasoning is the following: - I need to unsubscribe my streams in onStop()…
1
vote
0 answers

How to use combineLatest with multiple sources

I am using the RXKotlin combineLatest and I have a multiple source. but I am calling this like Observables.combineLatest(source1, source2) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe( { …
dotGitignore
  • 1,597
  • 2
  • 15
  • 34
1
vote
0 answers

Koin testing on Androidx with Activity

I am trying to do some instrumented tests of a boilerplate code after migrating it to AndroidX. Note that before migration, all of them worked, but after, only unit tests work, the instrumented test crashes on Null Pointer exception, where it…
Lukas Anda
  • 716
  • 1
  • 9
  • 30
1
vote
2 answers

RxJava/RxKotlin complains about accessing views

I have the following call to retrieve some data from server and update the UI according to response. poiAPIService.getPoiDetails(poiId!!) .observeOn(AndroidSchedulers.mainThread()) .doOnSubscribe { showProgressBar(true)…
Ilker Baltaci
  • 11,644
  • 6
  • 63
  • 79
1
vote
0 answers

RxRoom Kotlin: Generated Dao - error: local variable users is accessed from within inner class; needs to be declared final

I'm using RxRoom with Kotlin. In my Dao class If I use this: @Insert fun insertPaymentRef(paymentRef: PaymentRef): Single Or this: @Insert fun insertPaymentRef(paymentRef: PaymentRef): Completable the generated Dao class throws this…
1
vote
2 answers

Observable#take(Long) not returning desired size of items in RxJava

I am using RxJava/Kotlin Observable#take() to get first 50 items from the list. But #take() operator is not behaving as it should as per Rx docs. In Rx docs, #take() is defined as: "Emit only the first n items emitted by an Observable" I have a…
erluxman
  • 18,155
  • 20
  • 92
  • 126