Android StateFlow vs LiveData Example | NotesApp StateFlow | CheezyCode (Hindi)

Published: 15 September 2022
on channel: Cheezy Code
9,921
217

Android Tutorial For Beginners - Learn how to convert LiveData to StateFlow using Kotlin. We have simply converted our LiveData code to use Kotlin State Flow. We have replaced MutableLiveData with MutableStateFlow and LiveData with StateFlow. We could have exposed simple Flow object but for simplicity we exposed StateFlow object.

StateFlow is identical to LiveData but there are subtle differences with respect to Threading, Lifecycles. Kotlin Flows are dependent on Coroutine Scope. Lifecycle of Flow is driven by the Coroutine Scope. Whenever scope is destroyed, flow is also destroyed.

For consuming or collecting flow objects inside Fragments and Activities we have this extension function - repeatOnLifeCycle. This methods helps to prevent resource wastage and memory leaks. You can read more about this function here -

  / a-safer-way-to-collect-flows-from-android-uis  

Learn step by step - how to create a fully functional android app with simple example in Hindi.

Complete Dependency Injection Playlist Link -
   • Dagger 2 - Dependency Injection in Android  

Complete Android Architecture Components Playlist -
   • Android Architecture Components and Jetpac...  

Beginner series in Android Playlist (Hindi) -
   • Android Tutorials Step By Step In Hindi  

Kotlin Beginners Tutorial Series -
   • Kotlin Beginner Tutorials Hindi | Complete...  

For more info - visit the below link
http://www.cheezycode.com

Source Code -
https://github.com/CheezyCode/YetAnot...


We are social. Follow us at -
Facebook -   / cheezycode  
Twitter -   / cheezycode  
Instagram -   / cheezycode  


On this page of the site you can watch the video online Android StateFlow vs LiveData Example | NotesApp StateFlow | CheezyCode (Hindi) with a duration of hours minute second in good quality, which was uploaded by the user Cheezy Code 15 September 2022, share the link with friends and acquaintances, this video has already been watched 9,921 times on youtube and it was liked by 217 viewers. Enjoy your viewing!