Reputation:
I am new to android development and MVVM and try to understand Databinding and LiveData.
Also LiveData updates the view, when data changes in the viewmodel.
Why should I use LiveData, when DataBinding already does that in both one-way and two-way databinding?
What are the perks of using Databinding together with LiveData?
Upvotes: 2
Views: 186
Reputation: 157447
Why should I use LiveData, when DataBinding already does that in both one-way and two-way databinding?
LiveData is lifecycle aware. This means that the updates will be delivered to your UI when the Activity/Fragment is an state where those updates are meaningful.
What are the perks of using Databinding together with LiveData?
You get not worry about the lifecycle of your Activity/Fragment (livedata) and let Google generate the code to update your views for you (databinding).
Upvotes: 1