Skip to main content

Posts

Showing posts with the label map

Live Data. Difference between livedata and mutable live data. Mediator Live Data. Live Data Encapsulation

What is Live Data?   Live Data is one of the first architectural components. Live Data is a data holder class. Not only a simple data holder class, but having lot of features. We can say that it is a simple, lifecycle aware, observable, data holder class. Before introducing live data , we need to manually handle the updates in the UI. We were using traditional approaches like interfaces, events buses to update the UI. These traditional approaches having problem like manual handling of lifecycle, memory leaks, and crashes.  Live Data It is wrapper which can be used with any data such as data and objects that implements collections like list. A Live Data usually declared and used inside a view model class. Live Data can be used to observe the change of a particular data and update the UI based on that. Due to life cycle aware property we don't need to bother about components life cycle. i.e. it will send the update only when the component (activity/fragment)  is in active state. If t