Skip to content

Instantly share code, notes, and snippets.

@AlexGladkov
Created December 15, 2020 08:15
Show Gist options
  • Save AlexGladkov/e4d1fee50e778d7d2ecaf71fc330789e to your computer and use it in GitHub Desktop.
Save AlexGladkov/e4d1fee50e778d7d2ecaf71fc330789e to your computer and use it in GitHub Desktop.
/// Module
@Module
class SharedModule {
@Provides
fun provideConfigurationRepository(context: Context): ConfigurationRepository =
ConfigurationRepository(
localDataSource = CommonConfigurationDataSource(context),
remoteDataSource = MockConfigurationDataSource()
)
}
/// View Model function
private fun checkOpenedQuest() {
viewModelScope.launch {
val userConfiguration = configurationRepository.fetchConfiguration()
if (userConfiguration.currentQuestId >= 0) {
viewAction = QuestListAction.OpenQuestPage(
questId = userConfiguration.currentQuestId.toInt(),
questPage = userConfiguration.currentQuestPage.toInt()
)
} else {
fetchQuestList()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment