user11812815
user11812815

Reputation:

Understanding LiveData and DataBinding

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

Answers (1)

Blackbelt
Blackbelt

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

Related Questions