Last active
February 10, 2020 23:07
-
-
Save CDRussell/5143cca9a33fc8072604bc9a908c7c89 to your computer and use it in GitHub Desktop.
Previous setup of Activity and ViewModel
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 TabSwitcherActivity : Activity(), CoroutineScope by MainScope() { | |
override fun onNewTabRequested() { | |
launch { viewModel.onNewTabRequested() } | |
} | |
} |
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 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