Created
November 9, 2022 14:09
-
-
Save Vaibhav2002/013bc2e3e3599242cec82ce6879edfaa to your computer and use it in GitHub Desktop.
Collecting Flows using flowWithLifecycle
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
viewLifecycleOwner.lifecycleScope.launch { | |
//This extension function internally uses the repeatOnLifecycle API and makes the code cleaner | |
flow.flowWithLifecycle(Lifecycle.State.STARTED).collect { | |
// Doing the work | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment