Created
February 16, 2022 03:04
-
-
Save Farhandroid/3babff9be6964da40f16b64341d31b39 to your computer and use it in GitHub Desktop.
MovieRemoteDataSourceImpl
This file contains hidden or 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 MovieRemoteDataSourceImpl(private val movieApi: MovieApi, private val movieDB: MovieDB) : | |
MovieRemoteDataSource { | |
private val movieDao = movieDB.movieDao() | |
@OptIn(ExperimentalPagingApi::class) | |
override fun getPopularMovies(): Flow<PagingData<Movie>> { | |
val pagingSourceFactory = { movieDao.getAllMovies() } | |
return Pager( | |
config = PagingConfig(pageSize = 20), | |
remoteMediator = MovieRemoteMediator( | |
movieApi, | |
movieDB | |
), | |
pagingSourceFactory = pagingSourceFactory, | |
).flow | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment