RxPagination 0.0.3

RxPagination 0.0.3

khoitm 维护。



 
依赖
RxSwift~> 6.0
RxCocoa~> 6.0
RxSwiftExt~> 6.0
RxOptional~> 5.0
行为~> 5.0
 

  • Khoi Truong

RxPagination

这个库与 RxSwift 一起使用,以提供处理分页 API 的简单方法。RxPagination 也基于 Action

  • 一次只执行一个触发器(重新加载/下一页/上一页)。
  • 聚合个别执行中的后续/错误事件。

3 种不同的分页样式

  • PagingAction 使用 page/itemsPerPage
  • OffsettingAction 使用 offset/limit
  • CursoringAction 使用 next/previous

使用方法

let pagingAction: PagingAction<String, SampleResponse> = PagingAction<String, SampleResponse>(
    itemsPerPage: 10,
    removeDuplicates: { $0.id },
    request: { (input, page) in
        return api.getItems(for: input, page: page)
    }
)

...

pagingAction.allItems.subscribe(onNext: { items in
    print(items)
})

pagingAction.errors.subscribe(onError: { error in
    print(error)
})

...

pagingAction.reload("Some Input")
pagingAction.next("Some Input")

安装

CocoaPods

只需将以下行添加到 Podfile 中

pod 'RxPagination'

然后运行 pod install,一切都会好的👌

感谢

这个库受到了VinID的同事dangthaison91的启发,实现基于RxCommunity的Action。这些开发者值得很多感谢!

许可证

MIT.