Skip to content

Instantly share code, notes, and snippets.

@AgiMaulana
Created May 15, 2020 05:31
Show Gist options
  • Save AgiMaulana/76ab91bfb0c254daffef826502cc61f0 to your computer and use it in GitHub Desktop.
Save AgiMaulana/76ab91bfb0c254daffef826502cc61f0 to your computer and use it in GitHub Desktop.
Non null Android Clean Architecture's LiveData
open class NonNullLiveData<T>(private val defaultValue: T) : LiveData<T>() {
override fun getValue(): T = super.getValue() ?: defaultValue
protected 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