Advertisement
Guest User

Untitled

a guest
Apr 18th, 2015
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. import Async
  2. import SwiftTask
  3.  
  4. class AsyncTask {
  5. func background<T>(job: (((Float -> Void), (T -> Void), (NSError -> Void), SwiftTask.TaskConfiguration) -> Void)) -> SwiftTask.Task<Float, T, NSError> {
  6. return SwiftTask.Task<Float, T, NSError> { (progress: (Float -> Void), fulfill: (T -> Void), reject: (NSError -> Void), configure: SwiftTask.TaskConfiguration) -> Void in
  7. Async.background {
  8. job(progress, fulfill, reject, configure)
  9. return
  10. }
  11.  
  12. return
  13. }
  14. }
  15. }
  16.  
  17. let task = AsyncTask.background<MyAwesomeObject> { progress, fulfill, reject, configure in
  18. let obj = MyAwesomeObject()
  19. //-- ... do work here
  20. fulfill(obj)
  21. return
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement