Skip to content

Instantly share code, notes, and snippets.

@ceruleanotter
Created June 20, 2019 18:56
Show Gist options
  • Save ceruleanotter/00315271d8dd3c396fa9d7a52c7ad6bd to your computer and use it in GitHub Desktop.
Save ceruleanotter/00315271d8dd3c396fa9d7a52c7ad6bd to your computer and use it in GitHub Desktop.
ViewModel Integrations: LiveData & Saved State Module
// getLiveData gets MutableLiveData associated with a key.
// When the value associated with the key updates, the MutableLiveData does as well.
private val _userId : MutableLiveData<String> = savedStateHandle.getLiveData(USER_KEY)
// Only expose a immutable LiveData
val userId : LiveData<String> = _userId
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment