All Blogs

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.

crossinline in Kotlin

crossinline in Kotlin

crossinline in Kotlin is used to avoid non-local returns from a lambda that is passed to an inline function. We will learn it with a simple example.

inline function in Kotlin

inline function in Kotlin

An inline function in Kotlin tells the compiler to insert the complete body of the function wherever that function is called, which avoids the call overhead.

noinline in Kotlin

noinline in Kotlin

noinline in Kotlin is used when we do not want all the lambdas passed to an inline function to be inlined. We mark those lambda parameters as noinline.

Use setRecycledViewPool for Optimizing Nested RecyclerView

Use setRecycledViewPool for Optimizing Nested RecyclerView

setRecycledViewPool lets the inner RecyclerViews of a Nested RecyclerView share one view pool, so that views get reused and scrolling becomes smooth.