Swiftpack.co - Package - lukewar/Errands

Platform Swift support

CocoaPods Compatible Carthage compatible Swift Package Manager compatible

Twitter

Errands

Quick and simple way of running sequential asynchronous tasks.

Need for Errands came while building integration tests suite for Tunsgten project. Usually those tests consist of multiple sequential operations, where each step depends on results from previous step. Nevertheless testing usecase is not the only one that Errands could be used for.

Note: Errands and PromisKit share similarities in functionality. Errands put strong focus on creating custom operations quicker in expense of being less powerful.

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'
end

Then, install it by running the following command:

$ pod install

Carthage

To integrate Errands using Carthage, specify it as a dependency in your Cartfile:

github "lukewar/Errands" ~> 0.1.0

Run 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.

Github

link
Stars: 2
Help us keep the lights on

Dependencies

Used By

Total: