All Projects → fpg1503 → Asynchronous

fpg1503 / Asynchronous

Licence: mit
Implementation-agnostic asynchronous code

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Asynchronous

future.callr
🚀 R package future.callr: A Future API for Parallel Processing using 'callr'
Stars: ✭ 52 (+300%)
Mutual labels:  promises, asynchronous, futures
Tascalate Concurrent
Implementation of blocking (IO-Bound) cancellable java.util.concurrent.CompletionStage and related extensions to java.util.concurrent.ExecutorService-s
Stars: ✭ 144 (+1007.69%)
Mutual labels:  asynchronous, promises, async-programming
Tomorrowland
Lightweight Promises for Swift & Obj-C
Stars: ✭ 106 (+715.38%)
Mutual labels:  asynchronous, promises, futures
Swiftcoroutine
Swift coroutines for iOS, macOS and Linux.
Stars: ✭ 690 (+5207.69%)
Mutual labels:  asynchronous, promises, futures
Lwt
OCaml promises and concurrent I/O
Stars: ✭ 505 (+3784.62%)
Mutual labels:  asynchronous, promises, futures
Future
🚀 R package: future: Unified Parallel and Distributed Processing in R for Everyone
Stars: ✭ 735 (+5553.85%)
Mutual labels:  asynchronous, promises, futures
swift-futures
Demand-driven asynchronous programming in Swift
Stars: ✭ 32 (+146.15%)
Mutual labels:  promises, futures
ambi
Ambi lets you execute any function ambidextrously; providing you the ability to execute any function (be it synchronous, asynchronous, returns, callbacks, promises) as if it returned a promise.
Stars: ✭ 13 (+0%)
Mutual labels:  asynchronous, async-programming
apr
this is like caolan/async which is like lodash but async, but awaitful
Stars: ✭ 75 (+476.92%)
Mutual labels:  promises, async-programming
Creed
Sophisticated and functionally-minded async with advanced features: coroutines, promises, ES2015 iterables, fantasy-land
Stars: ✭ 265 (+1938.46%)
Mutual labels:  asynchronous, async-programming
ComposableAsync
Create, compose and inject asynchronous behaviors in .Net Framework and .Net Core.
Stars: ✭ 28 (+115.38%)
Mutual labels:  asynchronous, async-programming
await-mutex
Promised based Javascript Mutex
Stars: ✭ 36 (+176.92%)
Mutual labels:  promises, async-programming
Promesa
A promise library for Clojure(Script)
Stars: ✭ 277 (+2030.77%)
Mutual labels:  promises, async-programming
pg async.rs
Asynchronous, HA (master-master) PostgreSQL driver on top of libpq.
Stars: ✭ 40 (+207.69%)
Mutual labels:  asynchronous, futures
Rx.Book
High level asynchronous programming with Reactive Extensions
Stars: ✭ 67 (+415.38%)
Mutual labels:  asynchronous, async-programming
PromisedFuture
A Swift based Future/Promises framework to help writing asynchronous code in an elegant way
Stars: ✭ 75 (+476.92%)
Mutual labels:  asynchronous, futures
Zio
ZIO — A type-safe, composable library for async and concurrent programming in Scala
Stars: ✭ 3,167 (+24261.54%)
Mutual labels:  asynchronous, promises
Deferred
Work with values that haven't been determined yet.
Stars: ✭ 406 (+3023.08%)
Mutual labels:  futures, cocoapods
Asyncro
⛵️ Beautiful Array utilities for ESnext async/await ~
Stars: ✭ 487 (+3646.15%)
Mutual labels:  asynchronous, promises
aioudp
Asyncio UDP server
Stars: ✭ 21 (+61.54%)
Mutual labels:  asynchronous, async-programming

Asynchronous

CI Status Version License Platform Documentation codecov

Asynchronous 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, HydraAsync, PromiseKit, Promises, then and much more!

The 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!

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Sample use case

Let's say you're writing a mobile SDK that does asynchronous tasks (such as HTTP requests), just like the following:

func getUser(by id: String) -> Async<User> {
    return Async { resolve, reject in
        let url = APIRouter.route(for: .users, id: id)
        let request = URLRequest(url: url)

        let session = URLSession.shared
        let task = session.dataTask(with: request) { data, response, error in
            if let error = error {
                reject(error) // You can also `throw error`!
            } else if let data = data {
                do {
                    let user = try JSONDecoder().decode(User.self, from: data)
                    resolve(user)
                } catch (let error) {
                    reject(error)
                }
            } else {
                reject(NSError(domain: "my.domain", code: 123))
            }
        }
        task.resume()
    }
}

That's it! You simply create an Async and call resolve or reject once your task is finished.

The user can either add a completion block or use their favorite asynchronous abstraction:

Completion

apiClient.getUser(by: id).async { user, error in
    if let user = value {
        userName.text = user.name
    } else {
        display(error: error)
    }
}

Promise

apiClient.getUser(by: id).promise()
.then { user in
    userName.text = user.name
}.catch { error in
    display(error: error)
}

Installation

Async is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'Asynchronous'

Available Subspecs

Name Description
Asynchronous/Alamofire Alamofire support
Asynchronous/BrightFutures BrightFutures support
Asynchronous/HydraAsync HydraAsync support
Asynchronous/PromiseKit PromiseKit support
Asynchronous/Promises Promises support
Asynchronous/Then then support

Contributing

Contributions are encourajed and appreciated! For more information take a look at CONTRIBUTING.md.

Roadmap

  • [ ] ReactiveSwift support
  • [x] RxSwift support
  • [x] Tests
  • [x] Better documentation
  • [ ] Improved README
  • [x] Remove BrightFutures dependency
  • [ ] Carthage support
  • [ ] SwiftPM support
  • [x] Fix unnecessary error type erasures
  • [ ] Fix tuple gate in Asyncify
  • [ ] Improve Example project

Author

Francesco Perrotti-Garcia, [email protected]

License

Asynchronous is available under the MIT license. See the LICENSE file for more info.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].