Skip to content

Instantly share code, notes, and snippets.

@annchar
Created June 6, 2021 09:21
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save annchar/2d8dea860d8630bb55b2772d0b7cbad0 to your computer and use it in GitHub Desktop.
interface CryptoListRepository {
suspend fun getCryptoList(): LiveData<PagingData<CryptoItemResponse>>
}
class CryptoRepositoryImpl(
private val service: APIService,
private val mapper: CryptoListMapper
) : CryptoListRepository {
override suspend fun getCryptoList(): LiveData<PagingData<CryptoItemResponse>> {
return Pager(
config = PagingConfig(
pageSize = NETWORK_PAGE_SIZE,
enablePlaceholders = false
),
pagingSourceFactory = {
CryptoListPagingSource(service, mapper)
}
).liveData
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment