RxSwiftCommunity/RxPager

Name: RxPager

Owner: RxSwift Community

Description: Pager for RxSwift

Created: 2016-05-19 05:08:20.0

Updated: 2018-05-22 18:46:22.0

Pushed: 2018-04-09 05:05:09.0

Homepage: null

Size: 382

Language: Swift

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

RxPager

CI Status Version License Platform

Usage
ARK: Example 1

alias Page = [Int]
alias Callback = () -> Void

ake previous Page, and create next one
nextPage = { (previousPage: Page?) -> Observable<Page> in
last = previousPage?.last ?? 0
rn Observable.just([last + 1, last + 2, last + 3])


eturn true if there are more pages to be emitted
hasNext = { (page: Page) -> Bool in
d let last = page.last else { return true }
rn last < 10 // arbitrary condition for the demo


reate the pager
trigger = PublishSubject<Void>()
page$ = Observable.page(nextPage, while: hasNext, when: trigger)
next = trigger.onNext

$.subscribe(onNext: { print($0) })
rint [1, 2 ,3]

() // print [4, 5, 6]
() // print [7, 8, 9]
() // print [10, 11, 12]

ARK: Example 2 (page from array)

rvable
e(Array(1...10), by: 3, when: trigger)
scribe(onNext: { print($0) })

rint [1, 2 ,3]
() // print [4, 5, 6]
() // print [4, 5, 6]
() // print [10]

See Demo for more examples

Example

To run the example project, or run the playground, clone the repo, and run pod install from the Example directory first.

Requirements
Installation

RxPager is available through CocoaPods. To install it, simply add the following line to your Podfile:

"RxPager"
Credits

This pod is inspired by inspired by @mttkay work https://gist.github.com/mttkay/24881a0ce986f6ec4b4d and was refactored using ideas discussed here https://github.com/RxSwiftCommunity/RxSwiftExt/issues/30

License

RxPager is available under the MIT license. See the LICENSE file for more info.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.