Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. internal class ExampleViewModel : ViewModel() {
  2.  
  3. private val disposables = CompositeDisposable()
  4.  
  5. val showLoading = MutableLiveData<Boolean>()
  6.  
  7. val viewState = MutableLiveData<ExampleViewState>()
  8.  
  9. val posts = MutableLiveData<List<Post>>()
  10.  
  11. fun fetchPosts() {
  12. posts.value = emptyList()
  13. viewState.value = ExampleViewState.Empty
  14. }
  15.  
  16. data class Post(val name: String = "")
  17. }
  18.  
  19. sealed class ExampleViewState {
  20. object NetworkErrorState : ExampleViewState()
  21. object ErrorState : ExampleViewState()
  22. object Empty : ExampleViewState()
  23. object ShowList : ExampleViewState()
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement