Exploring LiveData and Kotlin Flow

A proper guide to learn when and where to use LiveData and Kotlin Flow

Siva Ganesh Kantamani
Programming Geeks

--

Photo by Fatos Bytyqi on Unsplash

Take away from this article

In this article, you’ll learn what and how to use Livedata & Kotlin flow. The key differences between them and a real-time example demonstrating the appropriate usage.

Introduction

LiveData is the means to transfer data, which is a common task in mobile development. Kotlin flow also has the ability to transfer data in a unique way and also perform async operations. Both have there limitations and advantages. They are designed to use in specific use-cases to overcome traditional problems.

What is LiveData?

In simple terms, Live data is an observable data holder class — meaning livedata can hold a set of data that can be observed from other android components like activities, fragments and services.

Live data is lifecycle aware — once the component which is observing data is destroyed or not active, livedata stops publishing data to that observer. This solves many conventional problems for Android developers.

Most of the developers use livedata in MVVM Architecture to communicate or transmit data from the ViewModel to view. This…

--

--