Skip to content

Instantly share code, notes, and snippets.

@antonicg
Created May 8, 2020 13:54
Show Gist options
  • Save antonicg/7dc1e0ba1287fbf7fc9938c3eed93cb9 to your computer and use it in GitHub Desktop.
Save antonicg/7dc1e0ba1287fbf7fc9938c3eed93cb9 to your computer and use it in GitHub Desktop.
// In an Android ViewModel you will use the viewModelScope:
viewModelScope.launch { someFlow.collect { /* do whatever */ } }
// In a Fragment we have the lifecycleScope :
lifecycleScope.launch { someFlow.collect { /* do whatever */ } }
// Or with the launchIn method:
someFlow.launchIn(viewModelScope)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment