Created
June 6, 2021 10:22
-
-
Save annchar/06dc8d17d9eac287fa75a276e3623aed 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
// for LiveData | |
override suspend fun getCryptoList(): LiveData<PagingData<CryptoItemResponse>> { | |
return Pager( | |
config = PagingConfig( | |
pageSize = NETWORK_PAGE_SIZE, | |
enablePlaceholders = false | |
), | |
pagingSourceFactory = { | |
CryptoListPagingSource(service, mapper) | |
} | |
).liveData | |
} | |
// for Flow | |
override suspend fun getCryptoList(): Flow<PagingData<CryptoItemResponse>> { | |
return Pager( | |
config = PagingConfig( | |
pageSize = NETWORK_PAGE_SIZE, | |
enablePlaceholders = false | |
), | |
pagingSourceFactory = { | |
CryptoListPagingSource(service, mapper) | |
} | |
).flow | |
} | |
// for Observable | |
override suspend fun getCryptoList(): Observable<PagingData<CryptoItemResponse>> { | |
return Pager( | |
config = PagingConfig( | |
pageSize = NETWORK_PAGE_SIZE, | |
enablePlaceholders = false | |
), | |
pagingSourceFactory = { | |
CryptoListPagingSource(service, mapper) | |
} | |
).observable | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment