{"id":15038402,"url":"https://github.com/fpg1503/asynchronous","last_synced_at":"2025-04-10T01:22:33.223Z","repository":{"id":56902473,"uuid":"109546649","full_name":"fpg1503/Asynchronous","owner":"fpg1503","description":"Implementation-agnostic asynchronous code","archived":false,"fork":false,"pushed_at":"2018-06-28T23:16:43.000Z","size":856,"stargazers_count":14,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-02T17:08:28.369Z","etag":null,"topics":["agnostic-implementation","async-programming","asynchronous","cocoapods","documented","futures","promise-library","promises","swift","swift-4","tested"],"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/fpg1503.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-05T02:47:29.000Z","updated_at":"2024-08-10T04:53:53.000Z","dependencies_parsed_at":"2022-08-20T18:50:28.446Z","dependency_job_id":null,"html_url":"https://github.com/fpg1503/Asynchronous","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fpg1503%2FAsynchronous","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fpg1503%2FAsynchronous/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fpg1503%2FAsynchronous/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fpg1503%2FAsynchronous/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fpg1503","download_url":"https://codeload.github.com/fpg1503/Asynchronous/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239108715,"owners_count":19583047,"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":["agnostic-implementation","async-programming","asynchronous","cocoapods","documented","futures","promise-library","promises","swift","swift-4","tested"],"created_at":"2024-09-24T20:38:19.175Z","updated_at":"2025-02-16T08:34:18.424Z","avatar_url":"https://github.com/fpg1503.png","language":"Swift","readme":"# Asynchronous\n\n[![CI Status](http://img.shields.io/travis/fpg1503/Asynchronous.svg?style=flat)](https://travis-ci.org/fpg1503/Asynchronous)\n[![Version](https://img.shields.io/cocoapods/v/Asynchronous.svg?style=flat)](http://cocoapods.org/pods/Asynchronous)\n[![License](https://img.shields.io/cocoapods/l/Asynchronous.svg?style=flat)](http://cocoapods.org/pods/Asynchronous)\n[![Platform](https://img.shields.io/cocoapods/p/Asynchronous.svg?style=flat)](http://cocoapods.org/pods/Asynchronous)\n[![Documentation](https://img.shields.io/cocoapods/metrics/doc-percent/Asynchronous.svg)](http://cocoadocs.org/docsets/Asynchronous/)\n[![codecov](https://codecov.io/gh/fpg1503/Asynchronous/branch/master/graph/badge.svg?token=tYItlSv7iF)](https://codecov.io/gh/fpg1503/Asynchronous)\n\n\nAsynchronous is a one-stop shop for your async needs, the user can use the subspecs to automatically run the Async code using completion handlers, [BrightFutures](https://github.com/Thomvis/BrightFutures), [HydraAsync](https://github.com/malcommac/Hydra), [PromiseKit](https://github.com/mxcl/PromiseKit), [Promises](https://github.com/khanlou/Promise), [then](https://github.com/freshOS/then) and much more!\n\nThe ultimate answer to **which asynchronous abstraction should I use in my API?**, just use `Asynchronous` and give your users freedom without the headache of adding several dependencies and different abstractions to your code!\n\n## Example\n\nTo run the example project, clone the repo, and run `pod install` from the Example directory first.\n\n## Sample use case\n\nLet's say you're writing a mobile SDK that does asynchronous tasks (such as HTTP requests), just like the following:\n```swift\nfunc getUser(by id: String) -\u003e Async\u003cUser\u003e {\n    return Async { resolve, reject in\n        let url = APIRouter.route(for: .users, id: id)\n        let request = URLRequest(url: url)\n\n        let session = URLSession.shared\n        let task = session.dataTask(with: request) { data, response, error in\n            if let error = error {\n                reject(error) // You can also `throw error`!\n            } else if let data = data {\n                do {\n                    let user = try JSONDecoder().decode(User.self, from: data)\n                    resolve(user)\n                } catch (let error) {\n                    reject(error)\n                }\n            } else {\n                reject(NSError(domain: \"my.domain\", code: 123))\n            }\n        }\n        task.resume()\n    }\n}\n```\n\nThat's it! You simply create an `Async` and call `resolve` or `reject` once your task is finished.\n\nThe user can either add a completion block or use their favorite asynchronous abstraction:\n\n### Completion\n```swift\napiClient.getUser(by: id).async { user, error in\n    if let user = value {\n        userName.text = user.name\n    } else {\n        display(error: error)\n    }\n}\n```\n\n### Promise\n```swift\napiClient.getUser(by: id).promise()\n.then { user in\n    userName.text = user.name\n}.catch { error in\n    display(error: error)\n}\n``` \n\n## Installation\n\nAsync is available through [CocoaPods](http://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod 'Asynchronous'\n```\n\n## Available Subspecs\n| Name | Description |\n|-------|------------|\n| `Asynchronous/Alamofire` | [Alamofire](https://github.com/Alamofire/Alamofire) support |\n| `Asynchronous/BrightFutures` |  [BrightFutures](https://github.com/Thomvis/BrightFutures) support |\n| `Asynchronous/HydraAsync` |  [HydraAsync](https://github.com/malcommac/Hydra) support |\n| `Asynchronous/PromiseKit` | [PromiseKit](https://github.com/mxcl/PromiseKit) support |\n| `Asynchronous/Promises` |  [Promises](https://github.com/khanlou/Promise) support |\n| `Asynchronous/Then` |  [then](https://github.com/freshOS/then) support |\n\n## Contributing\nContributions are encourajed and appreciated!\nFor more information take a look at [CONTRIBUTING.md](CONTRIBUTING.md).\n\n### Roadmap\n- [ ] ReactiveSwift support\n- [x] RxSwift support\n- [x] Tests\n- [x] Better documentation\n- [ ] Improved README\n- [x] Remove BrightFutures dependency\n- [ ] Carthage support\n- [ ] SwiftPM support\n- [x] Fix unnecessary error type erasures\n- [ ] Fix tuple gate in Asyncify\n- [ ] Improve Example project\n\n## Author\n\nFrancesco Perrotti-Garcia, fpg1503@gmail.com\n\n## License\n\nAsynchronous is available under the MIT license. See the LICENSE file for more info.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffpg1503%2Fasynchronous","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffpg1503%2Fasynchronous","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffpg1503%2Fasynchronous/lists"}