Skip to content

Instantly share code, notes, and snippets.

@AgiMaulana
Last active May 15, 2020 05:32
Show Gist options
  • Save AgiMaulana/bf51c5e3b5f3a59939e50b315068decc to your computer and use it in GitHub Desktop.
Save AgiMaulana/bf51c5e3b5f3a59939e50b315068decc to your computer and use it in GitHub Desktop.
Non null Android Clean Architecture's MutableLiveData
class NonNullMutableLiveData<T>(private val defaultValue: T) : NonNullLiveData<T>(defaultValue) {
public override fun getValue(): T = super.getValue() ?: defaultValue
public override fun setValue(value: T) = super.setValue(value)
public override fun postValue(value: T) = super.postValue(value)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment