All Blogs

Exception Handling in Kotlin Flow

Exception Handling in Kotlin Flow

In Kotlin Flow, we handle exceptions using the catch operator. The flow can complete with or without an exception, and catch lets us handle it gracefully.

Terminal Operators in Kotlin Flow

Terminal Operators in Kotlin Flow

Terminal operators in Kotlin Flow, like collect, are the operators that actually start the flow by connecting the flow builder and operators with the collector.

suspend function in Kotlin Coroutines

suspend function in Kotlin Coroutines

A suspend function in Kotlin Coroutines is a function that can be started, paused, and resumed, without blocking the thread. Let's see how it works.

Kotlin withContext vs Async-await

Kotlin withContext vs Async-await

withContext does not create a new coroutine. It only shifts the context of the current one, whereas async creates a new coroutine and we use await() for the result.

Room Database with Kotlin Coroutines

Room Database with Kotlin Coroutines

To use Room Database with Kotlin Coroutines, we mark the DAO functions with suspend and call them from a coroutine. We will build it with MVVM.

Parallel Multiple Network Calls Using Kotlin Coroutines

Parallel Multiple Network Calls Using Kotlin Coroutines

We can make multiple network calls in parallel using Kotlin Coroutines by starting each call with async and then calling await() on each to get the results.

Unit Testing ViewModel with Kotlin Coroutines and LiveData

Unit Testing ViewModel with Kotlin Coroutines and LiveData

To unit test a ViewModel with Kotlin Coroutines and LiveData, we mock the data layer with Mockito, use a TestCoroutineRule, and check the LiveData values.

What is System Design?

What is System Design?

System Design is the process of defining the components, APIs, and database tables of a system to satisfy the given functional and non-functional requirements.

MVVM Architecture - Android Tutorial

MVVM Architecture - Android Tutorial

MVVM (Model-View-ViewModel) is an Android architecture that removes tight coupling between components. We will learn it and build a project with it.