Код: Выделить всё
func myFunction() -> Promise {
firstly {
doSomeJob()
}.then { jobResult in
handleJobResult(jobResult)
}.then { handledResult in
return furtherJob(handledResult)
}
}
Код: Выделить всё
func simpleJob(_ jobResult: MyJobResult) -> Promise { ... }
func myFunction() -> Promise {
firstly {
doSomeJob()
}.then { jobResult in
if jobResult.allowsSimpleProcessing {
return simpleJob(jobResult)
// furtherJob must not be called.
// I want to step out of chain of promises.
}
handleJobResult(jobResult)
}.then { handledResult in
return furtherJob(handledResult)
}
}
Код: Выделить всё
doSomeJobдолжно быть
Код: Выделить всё
doSomeJobКак мне это написать?
Подробнее здесь: https://stackoverflow.com/questions/798 ... f-promises
Мобильная версия