Created
May 23, 2015 13:43
-
-
Save tokorom/19ae87acf9db5386c0e1 to your computer and use it in GitHub Desktop.
SwiftTask chain失敗の検証
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSLog("0. start") | |
self.request1() | |
.success { _ -> Task<Progress, Int, Bool> in | |
NSLog("1-2. request1 callback") | |
return self.request2() | |
} | |
.success { _ in | |
NSLog("2-2. request2 callback") | |
} | |
--------------------------------------------------- | |
func request1() -> Task<Progress, Int, NSError> { | |
return Task<Progress, Int, NSError> { progress, fulfill, reject, configure in | |
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(1.0 * Double(NSEC_PER_SEC))), dispatch_get_main_queue()) { | |
NSLog("1-1. request1 done") | |
fulfill(1) | |
} | |
} | |
} | |
func request2() -> Task<Progress, Int, Bool> { | |
return Task<Progress, Int, Bool> { progress, fulfill, reject, configure in | |
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(1.0 * Double(NSEC_PER_SEC))), dispatch_get_main_queue()) { | |
NSLog("2-1. request2 done") | |
fulfill(1) | |
} | |
} | |
} |
akio0911
commented
May 7, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment