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
3
votes
1 answer

AndThen executes before completable finished

Let's take two methods written with Rx: Maybe getFooFromLocal Single getFooFromNetwork I want to write a chain when we check our local storage for Foo. If we don't have any Foo we should get it from the network then save it to the local…
Sunstrike
  • 456
  • 1
  • 6
  • 22
3
votes
1 answer

RxKotlin (RxJava2) timeout() doesn't throw TimeoutException

I'm trying to get an example working that uses two different timeout values. An initial larger value for the first emission and then shorter values for all subsequent emissions. The example is converted to Kotlin from Java for RxJava v1x, although I…
junglie85
  • 1,243
  • 10
  • 30
3
votes
1 answer

How to dynamically update an RX Observable?

(Working in RxKotlin and RxJava, but using metacode for simplicity) Many Reactive Extensions guides begin by creating an Observable from already available data. From The introduction to Reactive Programming you've been missing, it's created from a…
Adam Hughes
  • 14,601
  • 12
  • 83
  • 122
3
votes
1 answer

Get N last objects emitted by observable in RxJava2

I have a Observables which emits some numbers and I simply want to take last N elements. I have following code (I'm using RxKotlin which is simply a wrapper on RxJava): val list = listOf(1,2,3,4,5,6,7,8,9,10) Observable.fromIterable(list) …
pezetem
  • 2,503
  • 2
  • 20
  • 38
3
votes
1 answer

Rx-Kotlin awaitTerminalEvent never getting onComplete

I am trying to get a better understanding of how to do unit tests with Rx-Kotlin, but I have not been able to successfully set the subject to "completed". As a result, I am always waiting for the timeout of 5 seconds (the onComplete should be…
sschmitz
  • 432
  • 5
  • 16
3
votes
2 answers

RxJava(Kotlin), Observable.amb and PublishSubject is not firing

We're trying to observe either a 15s interval, or whenever we're firing onNext on our subject refreshEventsSubject, but without success. The subject is initiated like so private val refreshEventsSubject = PublishSubject() And then we try to…
Hannes Lohmander
  • 1,315
  • 1
  • 8
  • 8
3
votes
1 answer

Expressing "super" generics in Kotlin functional types?

I'm trying to port an RxJava library and leverage extension functions in Kotlin. fun > Observable.collectWhile(factory: (() -> R), condition: (R,T) -> Boolean) = …
tmn
  • 11,121
  • 15
  • 56
  • 112
3
votes
1 answer

Using RxJava to join local data with remote ( or cached ) data

This is working code but I have a few questions as well as a request for advice on improving it. I am new to RxJava and I have not fully wrapped my head around how to chain these type of observables together. I have two model objects, ListItem and…
Matthew Smith
  • 4,387
  • 3
  • 15
  • 14
2
votes
2 answers

RXJava/Kotlin - Chaining Single results in one

I have a problem and I don't know how to resolve it with a better aproach. The problem is that I'm requesting to Spotify Web API and in some methods the artist image is returned and in others only basic artist info is obtained. I have this two…
abemart
  • 70
  • 2
  • 10
2
votes
2 answers

Retrofit - android.os.NetworkOnMainThreadException with RxKotlin

I've created rx function to call a network call from view-model in android, it parses network on main thread function. I just change few line of code it worked. but i need to know the reason for this because its use same builder pattern to create a…
2
votes
1 answer

Building a list from two observable sources in RxKotlin/RxJava using collectInto

I have a Category data class and a Plan data class. Each Category has a list of plan ids. There are Categories and Plans stored via Room. I am trying to construct a local List where I add each category to a list, and then add each of it's…
Tyler Pfaff
  • 4,900
  • 9
  • 47
  • 62
2
votes
1 answer

Extending Rx Singles zip infinitely

I need to make a lot of API calls asynchronously and obviously make sure that they all pass so I can handle error/success in a single place. Is there a way to easily extend Singles.zip() functionality in Kotlin to take more than base 9 parameters…
dem30
  • 113
  • 8
2
votes
1 answer

RxJava collect emitted values to array

How can I collect emitted values from observable to array? Input: Observable.just(1,2,3,4,5,6) Expected output: [1,2,3,4,5,6]
LeTadas
  • 3,436
  • 9
  • 33
  • 65
2
votes
1 answer

Reusing or recreating an observer?

I'm using a custom repository to get observables for data in a room database, e.g: fun getUsers(): Observable> = userDao.getAll() .toObservable() .subscribeOn(Schedulers.io()) …
Piwo
  • 1,347
  • 1
  • 12
  • 19
2
votes
2 answers

How to use MockK to mock an observable

I have a data provider that has an Observable as part of the public API. My class under test maps this into a Observable. How do I create a mock so that it can send out different values on the data provider's observable? I can do it…
Jim Leask
  • 6,159
  • 5
  • 21
  • 31