Last active
June 30, 2020 17:24
-
-
Save Eduardo-Nunes/78de57611617cd65eb9257b61ee8a1b3 to your computer and use it in GitHub Desktop.
Lifecycle observer lazy instance with Kotlin
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.LifecycleOwner | |
import androidx.lifecycle.Observer | |
infix fun <T : Any?> LifecycleOwner.lazyObserver(func: (T) -> Unit): Lazy<Observer<T>> { | |
return lazyOf(Observer(func)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment