{"id":26078304,"url":"https://github.com/danielepantaleone/resyncer","last_synced_at":"2025-08-24T13:21:02.105Z","repository":{"id":244671158,"uuid":"815803944","full_name":"danielepantaleone/Resyncer","owner":"danielepantaleone","description":"A swift library to make use of asynchronous API in a synchronous environment","archived":false,"fork":false,"pushed_at":"2025-04-07T08:26:17.000Z","size":449,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-21T08:08:58.236Z","etag":null,"topics":["ios","multithreading","swift","swift-concurrency","xcode"],"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/danielepantaleone.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":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-06-16T07:54:10.000Z","updated_at":"2025-04-14T11:58:56.000Z","dependencies_parsed_at":"2025-04-07T08:38:08.462Z","dependency_job_id":null,"html_url":"https://github.com/danielepantaleone/Resyncer","commit_stats":null,"previous_names":["danielepantaleone/resyncer"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/danielepantaleone/Resyncer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielepantaleone%2FResyncer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielepantaleone%2FResyncer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielepantaleone%2FResyncer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielepantaleone%2FResyncer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielepantaleone","download_url":"https://codeload.github.com/danielepantaleone/Resyncer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielepantaleone%2FResyncer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271873552,"owners_count":24837276,"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","status":"online","status_checked_at":"2025-08-24T02:00:11.135Z","response_time":111,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","multithreading","swift","swift-concurrency","xcode"],"created_at":"2025-03-09T03:57:43.747Z","updated_at":"2025-08-24T13:21:02.056Z","avatar_url":"https://github.com/danielepantaleone.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"![](https://github.com/danielepantaleone/Resyncer/blob/master/Banner.png?raw=true)\n\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fdanielepantaleone%2FResyncer%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/danielepantaleone/Resyncer)\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fdanielepantaleone%2FResyncer%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/danielepantaleone/Resyncer)\n![Cocoapods](https://img.shields.io/cocoapods/v/Resyncer?style=flat-square)\n![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/danielepantaleone/Resyncer?style=flat-square)\n![GitHub](https://img.shields.io/github/license/danielepantaleone/Resyncer?style=flat-square)\n[![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/danielepantaleone/Resyncer/swift-tests.yml?style=flat-square\u0026logo=github)](https://github.com/danielepantaleone/Resyncer/actions/workflows/swift-tests.yml)\n\nResyncer is a Swift library designed to seamlessly integrate asynchronous APIs within synchronous environments. It allows developers to call asynchronous code—whether using callbacks or Swift’s async/await pattern—and block the calling thread until the asynchronous task is complete. This ensures that a result is available before proceeding with the synchronous workflow, making it ideal for scenarios where sequential execution is critical, but asynchronous tasks are involved.\n\n## Table of contents\n\n* [Feature Highlights](#feature-highlights)\n* [Basic usage](#basic-usage)\n* [Installation](#installation)\n    * [Cocoapods](#cocoapods)\n    * [Swift Package Manager](#swift-package-manager)\n* [Contributing](#contributing)\n* [License](#license)\n\n## Feature Highlights\n\n- Compatible with iOS and macOS\n- No deadlocks\n- Support for callback based asynchronous code\n- Support for swift-concurrency based asynchronous code\n\n## Basic usage\n\nResyncer enables you to call asynchronous code within a synchronous environment by pausing the current thread until the asynchronous task completes. It achieves this by offloading the asynchronous work to a separate thread, either using an [OperationQueue](https://developer.apple.com/documentation/foundation/operationqueue) or leveraging Swift concurrency with [Task](https://developer.apple.com/documentation/swift/task).\n\n**Because Resyncer is going to block the calling thread, make sure not to use it from the Main Thread.**\n\n### Usage with callback based asynchronous code\n\nIf you have an asynchronous function that posts a value on a provided callback using swift `Result` (or also without `Result`, you can construct it yourself):\n\n```swift\nfunc asyncWork(_ completion: @escaping (Result\u003cInt, Error\u003e) -\u003e Void) { ... }\n```\n\nYou can use Resyncer to obtain the produced value in a synchronous environment:\n\n```swift\nlet x = try resyncer.synchronize { callback in\n    self.asyncWork { result in\n        callback(result)\n    }\n}\n```\n\n### Usage with swift-concurrency based asynchronous code\n\nIf you have an asynchronous function that returns a value:\n\n```swift\nfunc asyncWork() async throws -\u003e Int { ... }\n```\n\nYou can use Resyncer to obtain the produced value in a synchronous environment:\n\n```swift\nlet x = try resyncer.synchronize {\n    try await self.asyncWork()\n}\n```\n\n## Installation\n\n### Cocoapods\n\nAdd the dependency to the `Resyncer` framework in your `Podfile`:\n\n```ruby\npod 'Resyncer', '~\u003e 1.2.0'\n```\n\n### Swift Package Manager\n\nAdd it as a dependency in a Swift Package:\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/danielepantaleone/Resyncer.git\", .upToNextMajor(from: \"1.2.0\"))\n]\n```\n\n## Contributing\n\nIf you like this project you can contribute it by:\n\n- Submit a bug report by opening an [issue](https://github.com/danielepantaleone/Resyncer/issues)\n- Submit code by opening a [pull request](https://github.com/danielepantaleone/Resyncer/pulls)\n\n## License\n\n```\nMIT License\n\nCopyright (c) 2025 Daniele Pantaleone\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%2Fdanielepantaleone%2Fresyncer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielepantaleone%2Fresyncer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielepantaleone%2Fresyncer/lists"}