Created
September 9, 2019 08:16
-
-
Save uziassantosferreira/4d579e6d177dd495a8a69d498ca5dc2a to your computer and use it in GitHub Desktop.
ExampleViewModel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment