promisekit

Using PromiseKit to force sequential download

僤鯓⒐⒋嵵緔 提交于 2019-12-06 00:16:02
问题 I am using PromiseKit and would like to force sequential download of JSONs. The count of JSONs might change. I have read this about chaining. If I had a fixed number of say 3 downloads, this would be fine. But what if I had a changing count of download that I would like to download sequentially? This is my code for 2 URLs. I wonder how I could do this with dateUrlArray[i] iteration over the array? - (void)downloadJSONWithPromiseKitDateArray:(NSMutableArray *)dateUrlArray { [self

Swift Alamofire + Promise catching

£可爱£侵袭症+ 提交于 2019-12-05 20:42:00
Folks, The following works except for the catch, xcode errors out with expected member name following '.' Is this the proper way to promisify with PromiseKit? All suggestions welcome! Thanks! @IBAction func loginButtonTapped(sender: AnyObject) { let email = userEmail.text! let password = userPassword.text! func onSuccess(success:Bool, message:String, token: String) -> Promise<Void> { if success { NSUserDefaults.standardUserDefaults().setBool(true, forKey: "isUserLoggedIn") NSUserDefaults.standardUserDefaults().synchronize() self.dismissViewControllerAnimated(true, completion: nil) } else { let

Returning void in PromiseKit 6

*爱你&永不变心* 提交于 2019-12-04 06:41:52
This is what I had working with PromiseKit 4.5 api.getUserFirstName().then { name -> Void in print(name) } getUserFirstName() returns a Promsise<String> . I updated to PromiseKit 6 and this now throws an error: Cannot convert value of type '(_) -> Void' to expected argument type '(_) -> _' This error message makes little sense to me. How do I fix this? EDIT: So this seems to fix it, but I have little understanding as to what's happening with this: api.getUserFirstName().compactMap { name in print(name) } What's the difference now between then() and compactMap() ? In according with PromiseKit 6

Chain multiple Alamofire requests

我怕爱的太早我们不能终老 提交于 2019-11-26 18:20:44
I'm looking for a good pattern with which I can chain multiple HTTP requests. I want to use Swift, and preferrably Alamofire . Say, for example, I want to do the following: Make a PUT request Make a GET request Reload table with data It seems that the concept of promises may be a good fit for this. PromiseKit could be a good option if I could do something like this: NSURLConnection.promise( Alamofire.request( Router.Put(url: "http://httbin.org/put") ) ).then { (request, response, data, error) in Alamofire.request( Router.Get(url: "http://httbin.org/get") ) }.then { (request, response, data,

Chain multiple Alamofire requests

孤人 提交于 2019-11-26 06:17:08
问题 I\'m looking for a good pattern with which I can chain multiple HTTP requests. I want to use Swift, and preferrably Alamofire. Say, for example, I want to do the following: Make a PUT request Make a GET request Reload table with data It seems that the concept of promises may be a good fit for this. PromiseKit could be a good option if I could do something like this: NSURLConnection.promise( Alamofire.request( Router.Put(url: \"http://httbin.org/put\") ) ).then { (request, response, data,