Skip to content

Instantly share code, notes, and snippets.

@shakalaca
Created August 6, 2020 15:52
Show Gist options
  • Save shakalaca/7ed210b6b7561cc280a751fa9d036c90 to your computer and use it in GitHub Desktop.
Save shakalaca/7ed210b6b7561cc280a751fa9d036c90 to your computer and use it in GitHub Desktop.
class GithubRepository {
fun getSearchResultStream(query: String): Flow<PagingData<Repo>> {
val dbQuery = "%${query.replace(' ', '%')}%"
val pagingSourceFactory = { database.reposDao().reposByName(dbQuery)}
return Pager(
config = PagingConfig(pageSize = NETWORK_PAGE_SIZE, enablePlaceholders = false),
remoteMediator = GithubRemoteMediator(query, service, database),
pagingSourceFactory = pagingSourceFactory
).flow
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment