Swiftpack.co - JuanjoArreola/AsyncRequest as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by JuanjoArreola.
JuanjoArreola/AsyncRequest 2.3.0
Useful classes to handle asynchronous code
⭐️ 0
🕓 3 years ago
.package(url: "https://github.com/JuanjoArreola/AsyncRequest.git", from: "2.3.0")

AsyncRequest

Cocoapods Platform License codebeat badge

Useful classes to handle asynchronous code

A Request is an object containing closures that can be called asynchronously at some point in the future:

let request = Request<String>(successHandler: { string in
    print(string)
})

Depending on the result of some computation the request can be successful:

request.complete(with: "Success!")

Or not:

request.complete(with: TestError.error)

In any case the request finishes:

request.finished {
    print("did finish")
}

Requests can be canceled:

request.cancel()

Closures can be added:

request.success(handler: { string in
    print("Result: \(string)")
})

request.fail { error in
    print("Error: \(error)")
}

request.finished {
    print("request did complete")
})

GitHub

link
Stars: 0
Last commit: 3 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Related Packages

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics