Skip to content

Instantly share code, notes, and snippets.

@damianpetla
Created September 6, 2020 09:49
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 damianpetla/c9662007f1a4349a3368554e4224f657 to your computer and use it in GitHub Desktop.
Save damianpetla/c9662007f1a4349a3368554e4224f657 to your computer and use it in GitHub Desktop.
@Composable
fun LazyExampleWithIndex() {
val items = listOf("Cat", "Dog", "Monkey")//1000 of these
val lastIndex = items.lastIndex
LazyColumnForIndexed(items = items) { index, item ->
if (lastIndex == index) {
onActive {
//fetch more items from API
}
}
Text(text = "Item $item")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment