From the course: Android Development Essential Training: 3 Navigation
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Explore ViewModels and LiveData - Android Tutorial
From the course: Android Development Essential Training: 3 Navigation
Explore ViewModels and LiveData
- [Presenter] If you recall, the Android framework manages the life cycles of activities and fragments. It may decide to destroy or recreate them in response to certain user actions or device events, that are completely outside of your control. This is where ViewModels come into the picture. They allow you to store and manage UI data in a life cycle-conscious way. They're retained during configuration changes. This means that you won't have to worry about losing your UI related data when the framework chooses to destroy or recreate your components. And finally, ViewModels offer a more efficient way to handle asynchronous calls. They were designed to take the burden of managing these calls and their subsequent cleanup out of the hands of our UI controllers. A ViewModel is scoped to the life cycle associated with its creation. In this example, the ViewModel is associated with an activity. When the activity is first…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
(Locked)
Handle view events with lambdas3m 35s
-
(Locked)
Explore ViewModels and LiveData3m 11s
-
(Locked)
Add a ViewModel to an Activity4m 15s
-
(Locked)
Store and publish data in a ViewModel3m 22s
-
(Locked)
Subscribe to changes in LiveData values5m 11s
-
(Locked)
✓ Challenge: Take my order2m 9s
-
(Locked)
✓ Solution: Take my order2m 29s
-
(Locked)
-
-
-