Skip to content

Instantly share code, notes, and snippets.

@emrekose26
Created November 3, 2020 11:07
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 emrekose26/ccda77b3ece0638e5c4f308d6c2dcf07 to your computer and use it in GitHub Desktop.
Save emrekose26/ccda77b3ece0638e5c4f308d6c2dcf07 to your computer and use it in GitHub Desktop.
class PopularMoviesViewModel @ViewModelInject constructor(
private val repository: MoviesRepository
) : ViewModel() {
fun getPopularMovies(): Flow<PagingData<Movie>> {
return Pager(
config = PagingConfig(pageSize = PAGE_SIZE, enablePlaceholders = false),
pagingSourceFactory = { PopularMoviesPagingSource(repository) }
).flow
.cachedIn(viewModelScope)
}
companion object {
const val PAGE_SIZE = 20
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment