Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. /**
  2. * Observable manager for saving the [Cart]'s resource information.
  3. */
  4. class CartManager : LiveData<Resource<Cart?>>() {
  5.  
  6. init {
  7. value = Success(null)
  8. }
  9.  
  10. /**
  11. * Set the [Cart] value and notifies observers.
  12. */
  13. internal fun set(cart: Cart) {
  14. postValue(Success(cart))
  15. }
  16.  
  17. /**
  18. * Clear any information from the device.
  19. */
  20. internal fun clear() {
  21. postValue(Success(null))
  22. }
  23.  
  24. /**
  25. * Signals that the resource information is being retrieved from network.
  26. */
  27. internal fun loading() {
  28. postValue(Loading())
  29. }
  30.  
  31. /**
  32. * Signals that an error occurred when trying to fetch the resource information.
  33. */
  34. internal fun error(t: Throwable) {
  35. postValue(Failure(t))
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement