Description
ProcedureKit is a powerful framework for organizing, executing, and composing asynchronous operations in Swift. It abstracts the complexity of asynchronous programming, offering a simple and intuitive way to define and work with complex, asynchronous workflows. Whether you are making network requests, parsing data, or performing background tasks, ProcedureKit provides the tools you need to manage and coordinate your operations effectively.
Features
- Simple and intuitive API for managing asynchronous operations
- Highly composable: build complex workflows by chaining and combining smaller operations
- Supports cancellation, dependencies, and error handling
- Concurrent and sequential execution options
- Includes built-in operations for common tasks like network requests, file operations, and more
- Extensible architecture enables custom operation creation
- Full interoperability with Swift’s native concurrency model
Installation
To integrate ProcedureKit into your project, you can use CocoaPods or Swift Package Manager.
CocoaPods
You can install ProcedureKit via CocoaPods by adding the following line to your Podfile:
pod 'ProcedureKit'
Swift Package Manager
You can also use Swift Package Manager to add ProcedureKit to your project. Simply add a dependency to your Package.swift file:
dependencies: [
.package(url: "https://github.com/ProcedureKit/ProcedureKit.git", from: "6.0.0")
]
Documentation
For detailed usage instructions and API reference, check out the official ProcedureKit documentation.
Examples
Here are a few examples to help you get started with ProcedureKit:
- Create a simple procedure that performs a network request:
import ProcedureKit
class MyNetworkProcedure: Procedure {
override func execute() {
guard let url = URL(string: "https://api.example.com/data") else {
finish(withError: ProcedureKitError.invalidURL)
return
}
URLSession.shared.dataTask(with: url) { (data, response, error) in
// Process received data
// Finish procedure with success or error as needed
}.resume()
}
}
- Create a workflow by chaining multiple procedures:
let downloadProcedure = MyNetworkProcedure()
let parseProcedure = Procedure {
// Parse downloaded data
}
let saveProcedure = Procedure {
// Save parsed data to disk
}
parseProcedure.add(dependency: downloadProcedure)
saveProcedure.add(dependency: parseProcedure)
procedureQueue.add(operation: downloadProcedure)
procedureQueue.add(operation: parseProcedure)
procedureQueue.add(operation: saveProcedure)
Contributions
Contributions are welcome! If you have an improvement or a new feature you would like to see in ProcedureKit, please create a pull request. For major changes, please open an issue first to discuss the proposed changes.
License
ProcedureKit is available under the MIT license. See the LICENSE file for more information.
Contact
For any questions or inquiries, feel free to reach out to the ProcedureKit team at contact@procedurekit.org.