Created
September 6, 2020 09:57
-
-
Save damianpetla/e9965d7982c397a14d33cdd9f5649717 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
@ExperimentalCoroutinesApi | |
@Composable | |
fun LatestNewsFeed(viewModel: NewsViewModel) { | |
val state = viewModel.newsState.collectAsState() | |
val lastIndex = state.value.articles.lastIndex | |
LazyColumnForIndexed(items = state.value.articles) { i, newsItem -> | |
if (lastIndex == i) { | |
onActive { | |
viewModel.getMoreNews() | |
} | |
} | |
NewsCard(newsItem) { | |
viewModel.onSelectedNews(newsItem) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment