Created
March 31, 2022 19:22
-
-
Save smoralb/8e09883714c35ef7e485e106bbeb0a8f to your computer and use it in GitHub Desktop.
How a ViewModel can receive a lifecycle event and make some action.
This file contains 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
class SampleViewModel : LifecycleObserver { | |
… | |
@OnLifecycleEvent(Lifecycle.Event.ON_RESUME) | |
fun initializeCamera() { | |
if (camera == null) { | |
getCamera() | |
} | |
} | |
… | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment