Skip to content

Instantly share code, notes, and snippets.

@SabagRonen
Created October 1, 2018 07:27
Show Gist options
  • Save SabagRonen/76fba7e6bf20cd18617253029f875c7d to your computer and use it in GitHub Desktop.
Save SabagRonen/76fba7e6bf20cd18617253029f875c7d to your computer and use it in GitHub Desktop.
Why Should You Wrap LiveData With Your Own Abstraction - use directly
private val backgroundColorLiveData = MutableLiveData<Int>()
override fun observeTitleBackgroundColorWithDefaultValue(lifecycle: Lifecycle, observer: (Int) -> Unit) {
observer(R.color.colorAccent)
backgroundColorLiveData.observe({lifecycle}) {
it?.let(observer)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment