Skip to content

Instantly share code, notes, and snippets.

@eriadam
Created May 31, 2017 20:41
Show Gist options
  • Save eriadam/402a84aad956056798109530637eb183 to your computer and use it in GitHub Desktop.
Save eriadam/402a84aad956056798109530637eb183 to your computer and use it in GitHub Desktop.
Do Stuff Async Example
do {
// Closure
try self.doStuff(string: "Some string") { result in
print(result)
}
// Promise
let promise = try self
.doStuff(string: "Some other string")
promise.then { result -> Void in
print(result)
}
// Await
async {
let result = await(self.doStuff(string: "Yet another string"))
print(result)
}
} catch {
print(error)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment