Skip to content

Instantly share code, notes, and snippets.

@shkschneider
Last active November 27, 2018 09:18
Show Gist options
  • Save shkschneider/ea18290031f44fa0068bec3f9cafbce1 to your computer and use it in GitHub Desktop.
Save shkschneider/ea18290031f44fa0068bec3f9cafbce1 to your computer and use it in GitHub Desktop.
class MainViewModel : ViewModel() {
private lateinit var users: MutableLiveData<List<User>>
fun getUsers(): LiveData<List<User>> {
if (!::users.isInitialized) {
users = MutableLiveData()
// TODO loading of the data (hopefully using coroutines)
users.postValue(arrayListOf(
User(login = "user.name1"),
User(login = "user.name2")
))
}
return users
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment