Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- internal class ExampleViewModel : ViewModel() {
- private val disposables = CompositeDisposable()
- val showLoading = MutableLiveData<Boolean>()
- val viewState = MutableLiveData<ExampleViewState>()
- val posts = MutableLiveData<List<Post>>()
- fun fetchPosts() {
- posts.value = emptyList()
- viewState.value = ExampleViewState.Empty
- }
- data class Post(val name: String = "")
- }
- sealed class ExampleViewState {
- object NetworkErrorState : ExampleViewState()
- object ErrorState : ExampleViewState()
- object Empty : ExampleViewState()
- object ShowList : ExampleViewState()
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement