Skip to content

Instantly share code, notes, and snippets.

@Aidanvii7
Last active January 15, 2019 15:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Aidanvii7/818dbc037ab8ca72a3287a12734a0c2f to your computer and use it in GitHub Desktop.
Save Aidanvii7/818dbc037ab8ca72a3287a12734a0c2f to your computer and use it in GitHub Desktop.
class MyViewModel : ViewModel() {
@get:MainThread
val users: LiveData<List<String>> by unsafeLazy {
MutableLiveData<List<String>>().apply { loadUsersInto(this) }
}
private fun loadUsersInto(liveData: MutableLiveData<List<String>>) {
// do async operation to fetch users and update
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment