Questions tagged [rx-kotlin2]

RxKotlin 2 is a library that adds convenient extension functions to RxJava.

RxKotlin 2 is a lightweight library that adds convenient extension functions to RxJava 2 (see ). It can be found at https://github.com/ReactiveX/RxKotlin

106 questions
18
votes
2 answers

Chain Completable into Observable flow

Suppose you want to insert a Completable in your Observable chain, such as for each emitted element, there is a completable that runs and blocks until it completes, what option would you choose? (here the Completable.complete() is just to make an…
Adi B
  • 819
  • 1
  • 8
  • 11
8
votes
1 answer

RxJava Flowable.Interval backpressure when flatmap with single

I'm having a scenario where I need to periodically call an API to check for a result. I'm using Flowable.interval to create an interval function which calls the API. However, I'm having trouble with backpressure. In my example below, a new single is…
Richard
  • 14,427
  • 9
  • 57
  • 85
6
votes
3 answers

Simple HTTP request example in Android using Kotlin

I am new to Android development with Kotlin and I am struggling on finding any useful documentation on how to create a simple GET and POST requests with the best current practices as possible. I am coming from an Angular development and there we…
Gregor A
  • 217
  • 5
  • 16
4
votes
2 answers

Single causes either Network on Main Thread or View Root from Wrong Thread exceptions

Using a simple RxKotlin Single, I'm receiving either a android.view.ViewRootImpl$CalledFromWrongThreadException exception, or by adding .observeOn(AndroidSchedulers.mainThread()), I'm getting a NetworkOnMainThread exception. fun loadStaffCalendar()…
PatchesDK
  • 102
  • 2
  • 10
4
votes
1 answer

Android - Generic type as a Expressions In ObservableTransformer

I will be using observable transformer in my application for converting data from one type to another, so for this use i created a generic class with one parameter where T1 is the type am expecting to get the output Example class…
Stack
  • 1,164
  • 1
  • 13
  • 26
4
votes
2 answers

Converting loop with condition into RxJava stream

I have code that does blocking operation in while loop (downloads some data from a server). Client does not know how many items are going to be returned in each step. Loop breaks when N items are downloaded. val n = 10 val list =…
x2bool
  • 2,766
  • 5
  • 26
  • 33
3
votes
1 answer

Subscribing to 2 observables but only subscribe to the second one if a condition is true for the first one

RxJava 2 I have the following where I am subscribing to 2 observables it works ok. I don't think its the best way. I only want to subscribe to the second one getSalesInfo if the first one getProductDetails meets a condition. This is just a sample…
ant2009
  • 27,094
  • 154
  • 411
  • 609
3
votes
0 answers

How to mock completable of RxKotlin using MockK(Mock Framework)

For unit testing in kotlin android, I have been using the mocking framework MockK. Have used RxKotlin. I have used Completable observable to notify the ViewModel about the status of API. Based on the completable, the status will be updated to…
Raghul Vaikundam
  • 588
  • 4
  • 20
3
votes
2 answers

Lambda's are ignored until "run" is added

I have an rx chain that calls an API through Retrofit. I subscribe to my API service, with standard rx subscribe({...}) method and pass a lambda to it. Unfortunately when my call is finally completed, all the code I have added to be executed inside…
shadox
  • 3,238
  • 4
  • 24
  • 38
3
votes
3 answers

How to use RxJava2 combineLatest with a list of observables in Kotlin

I know how to do this in RxJava 2. And I know how RxKotlin helps with similar issues. But it seems that RxKotlin.Observables doesn't have this helper function for the list overload and I cannot figure it out. How would you do this?
Herrbert74
  • 2,578
  • 31
  • 51
2
votes
1 answer

Schedulers.io() Throwing NullPointerException in my Unit Tests

I'm trying to create unit tests for the method of my ViewModel below, which uses RxJava/RxKotlin. fun doLogin(address: String, serial: String) { mLoading.value = true mCompositeDisposable.add( mRepository …
2
votes
3 answers

How to use Rxjava for long running background task

I am using rxjava for some uploading task to server, Whenever task initiated fragment or activity is destroyed i will be disposing the subscription to avoid memory leak, But what i want is even after the fragment/activity destroyed i need to…
Stack
  • 1,164
  • 1
  • 13
  • 26
2
votes
1 answer

Convert Rxjava Completable to Map

I am need that i will be calling a completable method in the chain, after it completes, it needs to continue the chain with Map operator Example Single.just(someOperation()) .flatMapCompletable{ completableMethod() } .map{ //…
Stack
  • 1,164
  • 1
  • 13
  • 26
2
votes
1 answer

Android - Kotlin Sealed class with Rxkotlin filter

Since sealed is like enum object so i decided to use sealed class for network response, were it contains success or failure if it is success it contains data else error message Example sealed class Result { sealed class Success :…
Stack
  • 1,164
  • 1
  • 13
  • 26
2
votes
2 answers

RxJava: Ignore some errors in a Flowable

I have a Flowable and errors that are subtype of IgnoreThisError I want to ignore (resulting in graceful completion), all other errors should be propagated downstream. Kotlin example: val f : Flowable = ... val g = f.onErrorComplete { it is…
user3612643
  • 5,096
  • 7
  • 34
  • 55
1
2 3 4 5 6 7 8