{"id":13719657,"url":"https://github.com/tryswift/RxPagination","last_synced_at":"2025-05-07T11:32:32.650Z","repository":{"id":66354228,"uuid":"53716422","full_name":"tryswift/RxPagination","owner":"tryswift","description":"The demo project for \"Protocol-Oriented Programming in Networking\".","archived":false,"fork":false,"pushed_at":"2017-10-12T16:39:58.000Z","size":162,"stargazers_count":363,"open_issues_count":1,"forks_count":24,"subscribers_count":17,"default_branch":"master","last_synced_at":"2024-11-14T09:39:00.539Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tryswift.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2016-03-12T06:07:32.000Z","updated_at":"2024-10-12T12:28:43.000Z","dependencies_parsed_at":"2023-02-22T06:31:09.796Z","dependency_job_id":null,"html_url":"https://github.com/tryswift/RxPagination","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tryswift%2FRxPagination","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tryswift%2FRxPagination/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tryswift%2FRxPagination/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tryswift%2FRxPagination/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tryswift","download_url":"https://codeload.github.com/tryswift/RxPagination/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252869146,"owners_count":21816983,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T01:00:53.709Z","updated_at":"2025-05-07T11:32:28.679Z","avatar_url":"https://github.com/tryswift.png","language":"Swift","funding_links":[],"categories":["Libraries","Swift"],"sub_categories":[],"readme":"# RxPagination\n\nThis is the demo project for my presentation at try! Swift conference 2016.\n\n- Slides: https://speakerdeck.com/ishkawa/protocol-oriented-programming-in-networking\n- Video: https://news.realm.io/news/tryswift-yosuke-ishikawa-protocol-oriented-networking/\n\n## Set Up\n\n- `carthage bootstrap --platform iOS`\n\n## Requirements\n\n- Swift 3.0.1\n- Xcode 8.1\n\n## Summary\n\nThis demo project illustrates how to use RxSwift, Action and APIKit. The demo app fetches repositories via GitHub search API and displays them using the libraries.\n\n\u003cimg src=\"screenshot.png\" width=320\u003e\n\n### ViewModel\n\n`PaginationViewModel\u003cElement\u003e` is a view model for pagination. It has an initializer with type parameter `Request`, which is constrained to conform to `PaginationRequest` protocol. When `PaginationViewModel\u003cElement\u003e` is instantiated via `init\u003cRequest\u003e(baseRequest:)`, the type of its property that represents pagination elements will be inferred as `Observable\u003c[Request.Response.Element]\u003e`.\n\n```swift\nclass PaginationViewModel\u003cElement: Decodable\u003e {\n    let indicatorViewAnimating: Driver\u003cBool\u003e\n    let elements: Driver\u003c[Element]\u003e\n    let loadError: Driver\u003cError\u003e\n\n    init\u003cRequest: PaginationRequest\u003e(\n        baseRequest: Request,\n        viewWillAppear: Driver\u003cVoid\u003e,\n        scrollViewDidReachBottom: Driver\u003cVoid\u003e) where Request.Response.Element == Element {...}\n}\n```\n\n### ViewController\n\nOnce ViewModel is instantiated with a `Request` type parameter, remained task that ViewController have to do is binding input streams and output streams.\n\n\n```swift\nclass SearchRepositoriesViewController: UITableViewController {\n    @IBOutlet weak var indicatorView: UIActivityIndicatorView!\n\n    private let disposeBag = DisposeBag()\n    private var viewModel: PaginationViewModel\u003cRepository\u003e!\n\n    override func viewDidLoad() {\n        super.viewDidLoad()\n\n        let baseRequest = GitHubAPI.SearchRepositoriesRequest(query: \"Swift\")\n\n        viewModel = PaginationViewModel(\n            baseRequest: baseRequest,\n            viewWillAppear: rx.viewWillAppear.asDriver(),\n            scrollViewDidReachBottom: tableView.rx.reachedBottom.asDriver())\n\n        disposeBag.insert([\n            viewModel.indicatorViewAnimating.drive(indicatorView.rx.isAnimating),\n            viewModel.elements.drive(tableView.rx.items(cellIdentifier: \"Cell\", cellType: RepositoryCell.self)),\n            viewModel.loadError.drive(onNext: { print($0) }),\n        ])\n    }\n}\n```\n\n## Contact\n\nTwitter: https://twitter.com/_ishkawa\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftryswift%2FRxPagination","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftryswift%2FRxPagination","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftryswift%2FRxPagination/lists"}