I'm using PromiseKit to handle my network calls. I'm trying to see if there's a convention or a cleaner way to either fulfill or reject the promise early. As illustrated below, there are a few conditions that would require me to fulfill or reject early. I'm currently doing this by putting a return
statement right afterward. I feel like this is rather clunky and am wondering if there's a better way to do this. Thanks!
return PromiseKit { fulfill, reject in
if statusCode == 200 {
if conditionA {
if conditionB {
fulfill(...) // How do I stop the execution chain from here
return
} else {
reject(...) // Or here, without having to call return every time
return
}
}
reject(...)
}
}