Skip to content

Instantly share code, notes, and snippets.

@saqib-github-commits
Last active June 9, 2023 17:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saqib-github-commits/25b3f7beda75a2f88d80f144e5dfb6ba to your computer and use it in GitHub Desktop.
Save saqib-github-commits/25b3f7beda75a2f88d80f144e5dfb6ba to your computer and use it in GitHub Desktop.
// MainViewModel
class NewsViewModel (
private val newsRepository: NewsRepository = NewsRepositoryImpl()
) : ViewModel() {
init {
fetchNews()
}
private fun fetchNews() {
viewModelScope.launch {
newsRepository.fetchNews()
}
}
}
// MainScreen
@Composable
fun NewsScreen(viewModel: NewsViewModel = NewsViewModel()) {
LazyColumn{
// showing list of
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment