{"id":13338689,"url":"https://github.com/BilalReffas/Monitor","last_synced_at":"2025-03-11T10:31:44.019Z","repository":{"id":95094180,"uuid":"177423360","full_name":"BilalReffas/Monitor","owner":"BilalReffas","description":"A simple wrapper around NWPathMonitor","archived":false,"fork":false,"pushed_at":"2019-04-23T08:43:39.000Z","size":21,"stargazers_count":15,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-23T22:18:09.606Z","etag":null,"topics":["ios","macos","network","swift","tvos","watchos"],"latest_commit_sha":null,"homepage":"","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/BilalReffas.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-24T14:08:38.000Z","updated_at":"2024-07-22T21:02:02.000Z","dependencies_parsed_at":"2023-05-01T00:34:04.171Z","dependency_job_id":null,"html_url":"https://github.com/BilalReffas/Monitor","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/BilalReffas%2FMonitor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BilalReffas%2FMonitor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BilalReffas%2FMonitor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BilalReffas%2FMonitor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BilalReffas","download_url":"https://codeload.github.com/BilalReffas/Monitor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243015428,"owners_count":20222080,"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":["ios","macos","network","swift","tvos","watchos"],"created_at":"2024-07-29T19:17:08.511Z","updated_at":"2025-03-11T10:31:44.006Z","avatar_url":"https://github.com/BilalReffas.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Monitor\nMonitor is just a simple wrapper around NWPathMonitor. The monitor will receiving network path updates. So, whenever the network changes, the closure will get called and you can respond to changes in internet connectivity.\u003cbr\u003e\nApple is **strongly discouraging** to use SCNetworkReachability. Instead you should use NWPathMonitor. \u003cbr\u003e The Network framework is really powerful. I can highly recommend to watch [this](https://developer.apple.com/videos/play/wwdc2018/715/) WWDC Session.\n\n# Usage\nJust drop the Monitor.swift file into your project and use it as follows.\nThe Closure is running on the **background queue**.\n```swift\nclass ViewController: UIViewController {\n\n    override func viewDidLoad() {\n        super.viewDidLoad()\n        let monitor = Monitor()\n        monitor.startMonitoring { [weak self] connection, reachable in\n            guard let strongSelf = self else { return }\n            strongSelf.doSomething(connection, reachable: reachable)\n        }\n    }\n\n    private func doSomething(_ connection: Connection, reachable: Reachable) {\n        print(\"Current Connection : \\(connection) Is reachable: \\(reachable)\")\n    }\n}\n\n```\nThose are the information you can get. \n```swift\nenum Reachable {\n    case yes, no\n}\n\nenum Connection {\n    case cellular, loopback, wifi, wiredEthernet, other\n}\n```\n\n\n### Author\n\n  [@reffas_bilal](https://twitter.com/Reffas_Bilal)\n    \n### License\n\n```\nMIT License\n\nCopyright (c) 2019 Bilal Reffas\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBilalReffas%2FMonitor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FBilalReffas%2FMonitor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBilalReffas%2FMonitor/lists"}