All Blogs

RxJava Merge Operator

RxJava Merge Operator

The Merge operator of RxJava combines multiple Observables into one by merging their emissions. Unlike Concat, it does not maintain the order.

Long-running tasks in parallel with Kotlin Flow

Long-running tasks in parallel with Kotlin Flow

We can run long-running tasks in parallel with Kotlin Flow using the zip operator, which runs both tasks together and combines their results.

Retrofit with Kotlin Coroutines

Retrofit with Kotlin Coroutines

To use Retrofit with Kotlin Coroutines, we mark the API functions with suspend and call them from a coroutine inside the ViewModel. We will build it with MVVM.

coroutineScope vs supervisorScope

coroutineScope vs supervisorScope

A coroutineScope cancels all its children when any one child fails, whereas a supervisorScope does not cancel the other children when one of them fails.

Retrofit with Kotlin Flow

Retrofit with Kotlin Flow

To use Retrofit with Kotlin Flow, we wrap the suspend API call inside a flow builder and collect the result inside the ViewModel. We will build it with MVVM.

Room Database with Kotlin Flow

Room Database with Kotlin Flow

To use Room Database with Kotlin Flow, we return a Flow from the database layer, emit the data from Room, and collect it inside the ViewModel.

RxJava Concat Operator

RxJava Concat Operator

The Concat operator of RxJava emits the items of two or more observables one after another, without interleaving them, so the order is maintained.

dispose vs clear CompositeDisposable RxJava

dispose vs clear CompositeDisposable RxJava

In RxJava, clear() removes all the disposables but can accept new ones, whereas dispose() removes all of them and does not accept any new disposable.

RxJava Interval Operator

RxJava Interval Operator

The Interval operator of RxJava creates an Observable that emits a sequence of integers spaced by a given time interval. We use it to repeat a task.