Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. LiveData features -
  2. 1.Synchronous
  3. 2.Used for notifying
  4. 3.No memory leaks
  5. 4.No crashes
  6. 5.No manual lifecycle handling
  7. 6.It acts as a data holder.
  8.  
  9. Implementation steps -
  10. 1.Create LiveData instance to hold certain type of data.Usually done within ViewModel class.
  11. 2.Create Observer object that defines onChanged(), which controls what will happen when LiveData object held data changes.
  12. Usually Observer object is created in Activity/Fragment.
  13. 3.Attach Observer object to LiveData object using observe() method. observe() takes a LifecycleOwner object.This
  14. subscribes the Observer object to the LiveData object so that it will be notified of changes.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement