lukewar/errands
Quick and simple way of running sequential asynchronous tasks.
Usage
Running you firts Errands sequence is as simple as follows:
Errands().first { (done: @escaping DoneClosure<Void>) in
print("begin")
done(())
}.then { (_, done: @escaping DoneClosure<Void>) in
print("step")
done()
}.finally {
print("done")
}True value of Errands comes with easy information passing between steps. Following example logs in an user and loads her contacts.
Errands().first { (done: @escaping DoneClosure<User>) in
api.login(credentials) { user
done(user)
}
}.then { (loggedInUser, done: @escaping DoneClosure<[Contact]]>) in
api.loadContacts(loggedInUser) { contacts in
done(contacts)
}
}.finally { contacts in
print("User contacts: \(contacts).")
}Installation
Cocoapods
To integrate Errands using Cocoapods, specify it as a dependency in your Podfile:
platform :ios, '8.0'
use_frameworks!
target '<Your Target Name>' do
pod 'Errands'
endThen, install it by running the following command:
$ pod installCarthage
To integrate Errands using Carthage, specify it as a dependency in your Cartfile:
github "lukewar/Errands" ~> 0.1.0Run carthage update to build the framework and drag the built Errands.framework into your Xcode project.
Swift Package Manager
To integrate Errands using Swift Package Manager, specify it as a dependency in your Package.swift:
dependencies: [
.package(url: "https://github.com/lukewar/Errands.git", .upToNextMinor(from: "0.1.0"))
]Contribution
Please submit Pull Request against current development branch.
Licence
The MIT License (MIT)
Copyright (c) 2018 Lukasz Warchol
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Package Metadata
Repository: lukewar/errands
Default branch: master
README: README.md