Latest 0.1.1
License MIT
Platforms ios 8.0

Do.this is a Swift 3 quick async helper inspired by node.js Async


Do.this { this in

    //do stuff
    this.done(result: someResult)

}.then (name: "result step") { this in

    //do more stuff

    //every this has an index property and an optional name property
    //which can be useful for debugging and error handling
    print("this: ( ?? String(this.index))")

    //you can also access the previous result if needed:
    print("previousResult: (this.previousResult)")

    //if you're doing anything async, don't forget to call done()   
    DispatchQueue.main.asyncAfter(deadline: .now() + 2) {

        //async stuff

        //btw, result is optional

}.then (after: 2) { this in

    //you can also add a delay directly

}.then { this in

    //if an error happened, pass it in the done callback (you can still pass a result)
    //if you pass an error, the chain will break (see catch and finally below)
    let error = SomeError.bummer
    this.done(result: someResult, error: error)

}.then (on: .background)) { this in

    //this will execute in a background queue
    //(+you can combine this with a delay)
    print("on: (DispatchQueue.currentLabel)")
    this.done(result: someResult)

}.then (on: .main) { this in

    //this will be execute in the main queue
    //if you dont specify a queue, this will be executed on the current (last used) queue
    print("on: (DispatchQueue.currentLabel)")
    this.done(result: someResult)

}.catch { this in

    //catch an error, this will point to the step that triggered the error  
    print("catched error: (this.error) from ( ?? String(this.index))")

}.finally { this in

    //finally - will execute even if an error happened
    print("finally (previousResult: (this.previousResult))")


Swift 3


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

pod "Do.this"


Barak Harel


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

Latest podspec

    "name": "Do.this",
    "version": "0.1.1",
    "summary": "a quick async helper for Swift",
    "description": "Do.this is a Swift 3 quick async helper inspired by node.js Async",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": "Barak Harel",
    "platforms": {
        "ios": "8.0"
    "source": {
        "git": "",
        "tag": "0.1.1"
    "source_files": [
    "module_name": "DoThis",
    "pushed_with_swift_version": "3.0-GM-CANDIDATE"

Pin It on Pinterest

Share This