{"id":19685937,"url":"https://github.com/rxswiftcommunity/rxreachability","last_synced_at":"2025-04-05T05:08:59.720Z","repository":{"id":41548172,"uuid":"85860914","full_name":"RxSwiftCommunity/RxReachability","owner":"RxSwiftCommunity","description":"RxSwift bindings for Reachability","archived":false,"fork":false,"pushed_at":"2022-09-01T06:13:11.000Z","size":3469,"stargazers_count":283,"open_issues_count":1,"forks_count":79,"subscribers_count":8,"default_branch":"develop","last_synced_at":"2025-03-29T04:11:15.811Z","etag":null,"topics":["network","reachability","rxcocoa","rxswift","swift"],"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/RxSwiftCommunity.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null}},"created_at":"2017-03-22T18:10:46.000Z","updated_at":"2024-11-12T12:29:31.000Z","dependencies_parsed_at":"2022-07-07T16:30:26.434Z","dependency_job_id":null,"html_url":"https://github.com/RxSwiftCommunity/RxReachability","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RxSwiftCommunity%2FRxReachability","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RxSwiftCommunity%2FRxReachability/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RxSwiftCommunity%2FRxReachability/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RxSwiftCommunity%2FRxReachability/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RxSwiftCommunity","download_url":"https://codeload.github.com/RxSwiftCommunity/RxReachability/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247289429,"owners_count":20914464,"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":["network","reachability","rxcocoa","rxswift","swift"],"created_at":"2024-11-11T18:24:49.833Z","updated_at":"2025-04-05T05:08:59.696Z","avatar_url":"https://github.com/RxSwiftCommunity.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Logo](https://raw.githubusercontent.com/RxSwiftCommunity/RxReachability/master/Assets/Logo.png)\n\nRxReachability\n=========\n[![GitHub release](https://img.shields.io/github/release/RxSwiftCommunity/rxreachability.svg)](https://github.com/RxSwiftCommunity/rxreachability/releases)\n[![Version](https://img.shields.io/cocoapods/v/RxReachability.svg?style=flat)](http://cocoapods.org/pods/RxReachability)\n[![License](https://img.shields.io/cocoapods/l/RxReachability.svg?style=flat)](http://cocoapods.org/pods/RxReachability)\n[![Platform](https://img.shields.io/cocoapods/p/RxReachability.svg?style=flat)](http://cocoapods.org/pods/RxReachability)\n[![Build Status](https://travis-ci.org/RxSwiftCommunity/RxReachability.svg?branch=master)](https://travis-ci.org/RxSwiftCommunity/RxReachability)\n![Test Coverage](https://raw.githubusercontent.com/RxSwiftCommunity/RxReachability/master/docs/badge.svg)\n\nRxReachability adds easy to use RxSwift bindings for [ReachabilitySwift](https://github.com/ashleymills/Reachability.swift).\nYou can react to network reachability changes and even retry observables when network comes back up.\n\n## Available APIs\n\nRxReachability adds the following RxSwift bindings:\n\n- `reachabilityChanged: Observable\u003cReachability\u003e`\n- `status: Observable\u003cReachability.NetworkStatus\u003e`\n- `isReachable: Observable\u003cBool\u003e`\n- `isConnected: Observable\u003cVoid\u003e`\n- `isDisconnected: Observable\u003cVoid\u003e`\n\n## Common Usage\n\n#### 1. Be sure to store an instance of `Reachability` in your `ViewController` or similar, and start/stop the notifier on `viewWillAppear` and `viewWillDisappear` methods.\n\n```swift\nclass ViewController: UIViewController {\n\n  let disposeBag = DisposeBag()\n  var reachability: Reachability?\n\n  override func viewDidLoad() {\n    super.viewDidLoad()\n    reachability = Reachability()\n  }\n\n  override func viewWillAppear(_ animated: Bool) {\n    super.viewWillAppear(animated)\n    try? reachability?.startNotifier()\n  }\n\n  override func viewWillDisappear(_ animated: Bool) {\n    super.viewWillDisappear(animated)\n    reachability?.stopNotifier()\n  }\n}\n\n```\n\n#### 2. Subscribe to any of the bindings to know when a change happens.\n\n```swift\nextension ViewController {\n\n  let disposeBag = DisposeBag()\n\n  func bindReachability() {\n\n    reachability?.rx.reachabilityChanged\n      .subscribe(onNext: { reachability: Reachability in\n        print(\"Reachability changed: \\(reachability.currentReachabilityStatus)\")\n      })\n      .disposed(by: disposeBag)\n\n    reachability?.rx.status\n      .subscribe(onNext: { status: Reachability.NetworkStatus in\n        print(\"Reachability status changed: \\(status)\")\n      })\n      .disposed(by: disposeBag)\n\n    reachability?.rx.isReachable\n      .subscribe(onNext: { isReachable: Bool in\n        print(\"Is reachable: \\(isReachable)\")\n      })\n      .disposed(by: disposeBag)\n\n    reachability?.rx.isConnected\n      .subscribe(onNext: {\n        print(\"Is connected\")\n      })\n      .disposed(by: disposeBag)\n\n    reachability?.rx.isDisconnected\n      .subscribe(onNext: {\n        print(\"Is disconnected\")\n      })\n      .disposed(by: disposeBag)\n  }\n```\n\n## Static Usage\n\n#### 1. Be sure to store an instance of `Reachability` somewhere on your `AppDelegate` or similar, and start the notifier.\n\n```swift\nimport Reachability\n\n@UIApplicationMain\nclass AppDelegate: UIResponder, UIApplicationDelegate {\n\n  var reachability: Reachability?\n\n  func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -\u003e Bool {\n    reachability = Reachability()\n    try? reachability?.startNotifier()\n    return true\n  }\n}\n\n```\n\n#### 2. Subscribe to any of the bindings to know when a change happens.\n\n```swift\nimport Reachability\nimport RxReachability\nimport RxSwift\n\nclass ViewController: UIViewController {\n\n  let disposeBag = DisposeBag()\n\n  override func viewDidLoad() {\n    super.viewDidLoad()\n\n    Reachability.rx.reachabilityChanged\n      .subscribe(onNext: { reachability: Reachability in\n        print(\"Reachability changed: \\(reachability.currrentReachabilityStatus)\")\n      })\n      .disposed(by: disposeBag)\n\n    Reachability.rx.status\n      .subscribe(onNext: { status: Reachability.NetworkStatus in\n        print(\"Reachability status changed: \\(status)\")\n      })\n      .disposed(by: disposeBag)\n\n    Reachability.rx.isReachable\n      .subscribe(onNext: { isReachable: Bool in\n        print(\"Is reachable: \\(isReachable)\")\n      })\n      .disposed(by: disposeBag)\n\n    Reachability.rx.isConnected\n      .subscribe(onNext: {\n        print(\"Is connected\")\n      })\n      .disposed(by: disposeBag)\n\n    Reachability.rx.isDisconnected\n      .subscribe(onNext: {\n        print(\"Is disconnected\")\n      })\n      .disposed(by: disposeBag)\n  }\n```\n\n## Advanced Usage\n\nWith RxReachability you can also add a retry when network comes back up with a given timeout.\nThis does require you to have a stored instance of Reachability though.\n\n```swift\nfunc request(somethingId: Int) -\u003e Observable\u003cSomething\u003e {\n  return network.request(.something(somethingId))\n    .retryOnConnect(timeout: 30)\n    .map { Something(JSON: $0) }\n}\n```\n\n## Installation\n\n### Installation via CocoaPods\n\nTo integrate RxReachability into your Xcode project using CocoaPods, simply add the following line to your `Podfile`:\n\n```ruby\npod 'RxReachability', '~\u003e 1.2.1'\n```\n\n### Installation via Carthage\n\nTo integrate RxReachability into your Xcode project using CocoaPods, simply add the following line to your `Cartfile`:\n\n```ruby\ngithub \"RxSwiftCommunity/RxReachability\" ~\u003e 1.2.1\n```\n\n### Installation via Swift Package Manager (SPM)\n\nTo integrate RxReachability into your Xcode project using SPM, simply add the following line to your `Package.swift`:\n\n```swift\n.package(url: \"https://github.com/RxSwiftCommunity/RxReachability\", .upToNextMajor(from: \"1.2.1\")),\n```\n\n## Example\n\nTo run the example project, clone the repo, and run `pod install` from the Example directory first.\n\n## License\n\nThis library belongs to _RxSwiftCommunity_.\n\nRxReachability is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frxswiftcommunity%2Frxreachability","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frxswiftcommunity%2Frxreachability","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frxswiftcommunity%2Frxreachability/lists"}