craft
craft copied to clipboard
how to chaining multiple async ?
in the sample, i see you have 1 chaining for async, how to chain multiple async?
So you mean this? https://github.com/supertommy/craft/blob/master/craftTests/craftTests.swift#L171
Mean't Do* :) typing on an iPad Pro....
Sorry, I forgot to put more detail on it.
check the section resolve(value: true) and reject(value: false) after then....
how to use "resolve(value: true) and reject(value: false)" for the next then.... then....
func chainingMultipleAsync(completionHandler: ((isValid:Bool) -> Void)){ //chaining several alerts into one let promise = Craft.promise({ (resolve: (value: Value) -> (), reject: (value: Value) -> ()) -> () in AlertMessage("Warning!", defaultButton: "OK", alternateButton: "Cancel", otherButton: nil, docWindow: self.view.window!, completionHandler: { (returnInput) -> () in if returnInput == NSAlertFirstButtonReturn { resolve(value: true) }else{ reject(value: false) } }, contextInfo: nil, msgFormat: "The first one") }).then({ (value) -> Value in AlertMessage("Warning!", defaultButton: "OK", alternateButton: "Cancel", otherButton: nil, docWindow: self.view.window!, completionHandler: { (returnInput) -> () in if returnInput == NSAlertFirstButtonReturn { //NOTE: This need to go to resolve section of the next one resolve(value: true) }else{ //NOTE: This need to go to reject section of the next one reject(value: false) } }, contextInfo: nil, msgFormat: "The second one") }) { (value) -> Value in completionHandler(isValid: false) } .then({ (value) -> Value in completionHandler(isValid: false) }) { (value) -> Value in completionHandler(isValid: false) } }
any update on this? thanks