Skip to content

Instantly share code, notes, and snippets.

@uziassantosferreira
Created September 9, 2019 08:16
Show Gist options
  • Save uziassantosferreira/4d579e6d177dd495a8a69d498ca5dc2a to your computer and use it in GitHub Desktop.
Save uziassantosferreira/4d579e6d177dd495a8a69d498ca5dc2a to your computer and use it in GitHub Desktop.
ExampleViewModel
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