Learning Android Development

Cautious: LiveData Transformation Functions are Performed in MainThread

It is documented, but might not be noticed if we’re not careful

Photo by Nick Fewings on Unsplash

First of all, credit to Jossi Wolf for his excellent article below. Because of the article, it enlighten me on this info.

It took me a while to digest the content, hence I’m writing the summary gist of it, for my easier reference in the future, with a very simple design as an example.

Pre-requisite — Understand what LiveData is

Put it simply, LiveData is an intermediary communication between the View (Activity/Fragment) and its ViewModel.

Image from https://medium.com/mobile-app-development-publication/understanding-live-data-made-simple-a820fcd7b4d0

The benefit of LiveData are,

  • It is aware of the View’s lifecycle. It only gets the data through when the View is active

--

--