Using Kotlin Flow to handle streams of data
If we want our app to support pagination in the form of an infinite list, it's clear that our existing approach of having a single one-shot request to the backend that results in one UI update will not suffice.
Let's first have a look in the following code snippet at how our RepositoriesViewModel
class requests data:
class RepositoriesViewModel( private val restInterface: RepositoriesApiService = [...] ) : ViewModel() { val repositories = mutableStateOf(emptyList<Repository>()) init { viewModelScope.launch { repositories.value = restInterface.getRepositories().repos } &...