Created
September 20, 2019 16:58
-
-
Save TroyStopera/4f061cce797adc97547c3951e3886d91 to your computer and use it in GitHub Desktop.
LiveData observe lambda
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import androidx.lifecycle.* | |
fun <T> LiveData<T>.observe(lifecycleOwner: LifecycleOwner, callback: (T) -> Unit): Observer { | |
val observer = Observer(callback) | |
this.observe(lifecyleOwner, observer) | |
return observer | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment