Why do you need Livedata?
LiveData is lifecycle-aware.That means that only when the activity is in an active lifecycle state does the LiveData send an “on changed event”. If for example the activity is in the backstack, it won’t get notified on data changes until it becomes visible to the user again.
- No more manual lifecycle handling
- No crashes due to stopped activities
- No memory leaks
Since the LiveData observable takes control of firing the events, there is no need for us to handle lifecycle manually. This ensures that when using LiveData, the UI component is always up to date even when it becomes inactive at some point, as it receives the latest data upon becoming active again.
Read here to learn even more about it.

Comments
Post a Comment