Skip to content

marinehero/AsyncAwait

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 

Repository files navigation

AsyncAwait

A simple ascyncronous API written in Swift.

I created this project after seeing Microsoft's Async/Await API and decided to make a simple version of it in Swift.

See: https://msdn.microsoft.com/en-us/library/vstudio/hh191443(v=vs.110).aspx

Example:

func asyncMultiply(a: Int, b: Int) -> Task<Int> { // return type must be specified (i.e. Int)
  return Async {
    // anything in here will be executed asyncronously
    return a * b
  }
}

let task = asyncMultiply(101, 4) // Create and execute an asyncronous task

// Do other tasks here
print("Waiting...")

let result = Await(task) // Wait for the task to finish. Result will be Int
print(result) // 404

See the playground for more examples.

About

A simple ascyncronous API written in Swift.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Swift 92.9%
  • Objective-C 7.1%