-
-
Save CristianMG/359981aab5c466ead3c929172e3eadc0 to your computer and use it in GitHub Desktop.
Android paging Network + Database 4 snippet
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
| /** | |
| * For a clean architecture | |
| * encapsulated all methods for paginate in this class | |
| * | |
| * For more information | |
| * @see https://github.com/googlesamples/android-architecture-components/blob/master/PagingWithNetworkSample | |
| **/ | |
| interface Listing<T> { | |
| fun getBoundaryCallback(): LiveData<GenericBoundaryCallback<T>> | |
| fun getDataSource(): LiveData<PagedList<CharacterModel>> | |
| fun getNetworkState(): LiveData<NetworkState> = Transformations.switchMap(getBoundaryCallback()) { it.networkState } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment