Async: Arguments and return values to blocks

Currently Async supports passing parameters through an external var like:

var date: NSDate?
Async.background {
    date = NSDate()
}.main {
    // Access date 
}

Possible syntax for a better solution:

Async.background {
    let date = NSDate()
}.main(date) {
    // Access date
}

I have no idea if or how this is possible – please let me know if you do!

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 15 (6 by maintainers)

Most upvoted comments

This has actually been implemented in the Swift 3.0 branch.

Huge thanks to @BrunoMazzo for taking the big steps in making this work!!