Last active
February 26, 2020 23:10
-
-
Save Nimrodda/2583cb6d88bc8b70785a548080b87efa to your computer and use it in GitHub Desktop.
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 DetailViewModel( // Remove @Inject annotation from here | |
private val handle: SavedStateHandle | |
private val githubApi: GithubApi, | |
) : ViewModel() { | |
fun loadData() { | |
val id = handle["id"] ?: "default" | |
viewModelScope.launch { | |
val response = githubApi.getCommit(id) | |
// Handle response | |
} | |
} | |
} | |
class DetailViewModelFactory @Inject constructor( | |
private val githubApi: GithubApi | |
) : ViewModelAssistedFactory<DetailViewModel> { | |
fun create(handle: SavedStateHandle) { | |
return DetailViewModel(handle, githubApi) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment