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
115
votes
6 answers

How Kotlin coroutines are better than RxKotlin?

Why would I want to use Kotlin's coroutines? It seems that the RxKotlin library is much more versatile. Kotlin's coroutines look significantly less powerful and more cumbersome to use in comparison. I base my opinion on coroutines on this design…
charlie_pl
  • 2,898
  • 4
  • 25
  • 39
36
votes
1 answer

Use RxAndroid or RxKotlin when programming in Kotlin for Android?

I am going to start using reactive programming in my Android project. I am using Kotlin as primary language and now I would like to apply Rx. My first choice was RxAndroid but then I noticed that there is RxKotlin. As far as I know both are forked…
Damian Petla
  • 8,963
  • 5
  • 44
  • 47
27
votes
4 answers

Kotlin merge two nullable mutable list

val mutableList1: MutableList? val mutableList2: MutableList? addAll method can be use to merge nullable mutable list but, here it throws me compile time error. Example: val map1 = listOne?.map {…
QuokMoon
  • 4,387
  • 4
  • 26
  • 50
22
votes
4 answers

RxJava 2 overriding IO scheduler in unit test

I'm trying to test the following RxKotlin/RxJava 2 code: validate(data) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .flatMap { ... } I'm attempting to override the schedulers as follows: // Runs before each…
Alex
  • 739
  • 1
  • 6
  • 18
21
votes
7 answers

How to pass null to an Observable with nullable type in RxJava 2 and Kotlin

I initialize my variable like this:- val user: BehaviorSubject user = BehaviorSubject.create() But I can't do this. IDE throws an error:- user.onNext(null) And doing this, IDE says u will never be null:- user.filter( u -> u!=null)
Abhinav Nair
  • 958
  • 1
  • 8
  • 29
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
13
votes
2 answers

Kotlin lambda syntax confusion

I'm confused by Kotlin lambda syntax. At first, I have .subscribe( { println(it) } , { println(it.message) } , { println("completed") } ) which works fine. Then I moved the onNext to another class called…
pt2121
  • 11,720
  • 8
  • 52
  • 69
12
votes
2 answers

Rx Kotlin: map function can't infer return type

In an app that connects to bluetooth devices, I am using the following function using RxKotlin: private fun startBluetoothPair(device: BluetoothDevice) { Observable.just(device) .subscribeOn(Schedulers.io()) …
Marcel50506
  • 1,280
  • 1
  • 14
  • 32
11
votes
8 answers

How to read JSON from Url using kotlin Android?

Am using kotlin for developing the application.Now i want to get JSON data from server. In java am implemented Asyntask as well as Rxjava for read JSON from Url . Am also search in google but i cant get proper details for my requirement. How can i…
sasikumar
  • 12,540
  • 3
  • 28
  • 48
11
votes
3 answers

How to zip few observables in Kotlin language with RxAndroid

I have some problem. I'm a beginer in RxJava/RxKotlin/RxAndroid, and dont understand some features. For Example: import rus.pifpaf.client.data.catalog.models.Category import rus.pifpaf.client.data.main.MainRepository import…
Scrobot
  • 1,911
  • 3
  • 19
  • 36
10
votes
4 answers

What is the difference between rxjava2 and rxkotlin?

What is the difference between rxjava2 dependency and rxkotlin dependency. If I'm using rxkotlin dependency, should i need to add rxjava2 dependency along with that. implementation 'io.reactivex.rxjava2:rxkotlin:x.y.z' // do i need to add the below…
Manoj Perumarath
  • 9,337
  • 8
  • 56
  • 77
10
votes
1 answer

RxJava 2.0 and Kotlin Single.zip() with list of singles

I have issue that I cannot solve. Im trying to .zip(List, ) multiple Singles into one using Kotlin and none of Functions i supply as second argument fits. fun getUserFriendsLocationsInBuckets(token: String) { …
Efka
  • 134
  • 2
  • 7
10
votes
4 answers

Create New Instance of Kotlin Object

I have an object QuickSort that I am attempting to create 2 instances of. When I try to create 2 separate instances I can see that it is only using one instance because I have a count in the QuickSort class that is inaccurate. Kotlin does not use…
AdamHurwitz
  • 9,758
  • 10
  • 72
  • 134
8
votes
2 answers

What is the use case for doOnSuccess vs onSuccess in rxJava

I'm confusing about use case for doOnSuccess in rxJava. Let's see the code: Case 1: networkApi.callSomething() .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .doOnSuccess(__ ->…
Bulma
  • 990
  • 3
  • 16
  • 35
8
votes
3 answers

How to do a groupBy and collect using RxJava and Kotlin?

I have got Observable and Rate is just a simple object: Rate(val value:String){} Rates(val rates: List) and i wanna change that Observable into Observable. so for example for rates…
Łukasz Woźniczka
  • 1,625
  • 3
  • 28
  • 51
1
2 3
15 16