![]() ![]() Using LiveData provides the following advantages: Ensures your UI matches your data state LiveData follows the observer pattern. Unsubscribed when their lifecycles are destroyed.įor more information about how to use LiveData, see Work with LiveData This is especially useful for activities and fragments because they can safelyĪnd not worry about leaks-activities and fragments are instantly This relationship allows the observer to be removed when the state of You can register an observer paired with an object that implements the LiveData only notifies active observers about updates. LiveData considers an observer, which is represented by the Note: To import LiveData components into your Android project, see Adding This awareness ensures LiveData only updates appĬomponent observers that are in an active lifecycle state. ![]() ![]() Meaning it respects the lifecycle of other app components, such as activities,įragments, or services. Unlike a regular observable, LiveData is lifecycle-aware, ![]()
0 Comments
Leave a Reply. |