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

Moving Window With Kotlin Flow

I am trying to create a moving window of data using Kotlin Flows. It can be achieved in RxKotlin using a buffer, but buffer is not the same using Flows. RxKotlin has a buffer operator, periodically gathers items emitted by an Observable into bundles…
Sprout
  • 630
  • 1
  • 5
  • 22
7
votes
3 answers

RxJava Maybe: Any neat way to handle Empty case?

I am stuck at this problem, which should be fairly simple. I need subscriber to execute a code block when the Maybe has completed as an Empty Maybe. I found that we can pass default Maybe value or use switchIfEmpty but I feel both are hacky. Also…
Mangat Rai Modi
  • 5,397
  • 8
  • 45
  • 75
7
votes
1 answer

RxJava 2 equivalent to isUnsubscribed

I've been working through the examples in the book Reactive Programming with RxJava, which is targeted at version 1 not 2. An introduction to infinite streams has the following example (and notes there are better ways to deal with the…
junglie85
  • 1,243
  • 10
  • 30
7
votes
6 answers

Cant 'observeOn' main thread with RxKotlin

I'm trying to observe observable on main thread by using: // Kotlin Code Observable .observeOn(AndroidSchedulers.mainThread()) but I'm getting following error: Type Mismatch: Required: rx.Scheduler! Found:…
Nathan Horrigan
  • 763
  • 1
  • 9
  • 20
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
6
votes
3 answers

RxJava2. Execute a request for every item in a list

I have a list List FileModel is just a class contains id: Int id - is ID of photo file I need to fetch and cast to Bitmap I have a request: fun getFile(fileId: Int): Single This request returns ResponseBody which we can…
xskit
  • 421
  • 1
  • 8
  • 20
6
votes
2 answers

How can I convert this rxjava/rxkotlin flatMap into lambda expression?

Observable.just(1) .flatMap(object : Function> { override fun apply(integer: Int): Observable { return Observable.just(integer * 10) } }) …
s-hunter
  • 24,172
  • 16
  • 88
  • 130
6
votes
1 answer

Chaining multiple calls RxJava, Room and Retrofit

I am using RxJava/Kotlin with Room and Retrofit. I am sure I'm not making something write as I just started learning RxJava. The scenario is that I make a call to check if there are favorite records in DB and get them in a List, fetch data from API…
Esteban
  • 667
  • 9
  • 22
6
votes
1 answer

RxAndroid - retry observable on click

I'm using rxAndroid and rxKotlin in my Android app to handle network requests asynchronously. Now I would like to retry a failed network request only after click on Snackbar button. My code now: val citiesService =…
Michael
  • 187
  • 1
  • 2
  • 7
6
votes
1 answer

Behavior with Kotlin Higher-Order Functions and Single-method interfaces?

I was having some issues using RxJava and Kotlin earlier. I made some interesting discoveries which I'm still puzzled about. There is the simple Func1 interface in RxJava public interface Func1 extends Function { R call(T t); } I was…
tmn
  • 11,121
  • 15
  • 56
  • 112
5
votes
2 answers

How to chain "Single - Completeable - Completable" in rxkotlin?

I am a beginner with rxjava/rxkotlin/rxandroid. I need to deal with three diferent async-calls in a sequence. The problem is that the first step returns a Single, the second a Completableand the third again a Completable. (Single ->…
Appyx
  • 1,145
  • 1
  • 12
  • 21
4
votes
1 answer

Unit Test : Observer onChanged should be called twice instead of once

Why do I get different results when unit testing my ViewModel? I got two tests. When I launch each test individually that's ok but when I launch all tests in a row I got an error. It's a ViewModel that change state each time I got a return from an…
4
votes
2 answers

How to add Body in Url in Volley request in Kotlin?

Here is my Code that for Volley Request:- val searchRequest = object : JsonArrayRequest(Request.Method.GET,url, Response.Listener { response -> val result = response.toString() }, …
4
votes
2 answers

How to parse below Json data in Kotlin?

I need to parse this information- [ { "artist": "12", "image": "23" }, { "video_id": "12", "video_title": "23" }, { "video_id": "12", "video_title": "23" }, { "video_id": "12", "video_title": "23" }, { "video_id":…
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
1
2
3
15 16