Skip to content

Instantly share code, notes, and snippets.

@CDRussell
Last active February 10, 2020 23:07
Show Gist options
  • Save CDRussell/5143cca9a33fc8072604bc9a908c7c89 to your computer and use it in GitHub Desktop.
Save CDRussell/5143cca9a33fc8072604bc9a908c7c89 to your computer and use it in GitHub Desktop.
Previous setup of Activity and ViewModel
class TabSwitcherActivity : Activity(), CoroutineScope by MainScope() {
override fun onNewTabRequested() {
launch { viewModel.onNewTabRequested() }
}
}
class TabSwitcherViewModel(private val tabRepository: TabRepository) : ViewModel() {
suspend fun onNewTabRequested() {
tabRepository.add() // this is a `suspend` function
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment