Created
November 3, 2020 11:07
-
-
Save emrekose26/ccda77b3ece0638e5c4f308d6c2dcf07 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
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