Skip to content

Instantly share code, notes, and snippets.

@digitalbuddha digitalbuddha/RxPaging.kt
Last active Aug 24, 2018

What would you like to do?
class RxPaging {
var page = 1
val cache = CacheBuilder.newBuilder().build<Any, Single<List<Single<Int>>>>()
fun getPages() {
val tab1 = pagedList().blockingGet().iterator()
val tab2 = pagedList().blockingGet().iterator()
val a =
val b =
val c =
val d =
val e =
private fun pagedList() = cache.get("", { dbPages() })!!
private fun dbPages() = Single.just(listOf(dbPage(), dbPage(), dbPage())).cache()
private fun dbPage() = Single.fromCallable { nextPage() }.cache() //replace with DAO.getItems(offset,pageSize)
private fun nextPage(): Int = page++
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.