#3 Android LiveData Tutorial - Android LiveData example - Android MVVM tutorial

Publié le: 04 février 2020
sur la chaîne: Munir Hoque
1,756
23

Today our Topic is android LiveData. We will learn how to use android LiveData to update UI data inside Fragment or Activity from ViewModel.

Starter Project download link : https://bit.ly/2UmN4bt
Second part(Android ViewModel Tutorial) link -    • #2 Android ViewModel Tutorial - Andro...  
Full Playlist link :    • Android ViewModel and LiveData  

LiveData is an android architecture component which fundamentally has 2 attributes -
Observable Data Holder - holds data as a wrapper that holds any data. LiveData is an Observable that being observed by the Fragment , which means when the data inside the LiveData changes the Fragment gets notified and UI get refreshed automatically
Lifecycle aware - LiveData knows the state of View whether it is in background or foreground. If the View is in background LiveData automatically stops updating the View. So we do not need to manually configure the observer operations
Combining these 2 powerful properties we can say LiveData does Right things in Right time.

Right now what happens, our PuzzleFragment has a direct reference to the PuzzleViewModel, but ViewModel, in our case PuzzleViewModel has no clue which Views are using the ViewModel. We need something to notify any data changes to View and automatically update the UI. We can do this thing using LiveData. LiveData works as an observable wrapper and also lifecycle aware as I said earlier. LiveData automatically does the right things at the right time and thus saves us from many lifecycle related potential bugs and memory leaks.

Source code for this tutorial: https://bit.ly/381I3sS

#AndroidLiveData
#AndroidLiveDataTutorial
#MVVMTutorial
#AndroidAppDevelopmentTutorial
#AndroidMVVM


Sur cette page du site, vous pouvez voir la vidéo en ligne #3 Android LiveData Tutorial - Android LiveData example - Android MVVM tutorial durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Munir Hoque 04 février 2020, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 1,756 fois et il a aimé 23 téléspectateurs. Bon visionnage!