我目前正在研究是否应该将 PromiseKit 集成到现有项目中。
我的主要问题是我需要实现一个可以调用最多 5 个 Web 服务的业务逻辑。其中一些是根据之前的结果来调用的。
我当前的架构基于将代码分解为多个函数,并使用相互调用的闭包。
我试图找出是否可以使用 PromiseKit (或其他任何东西)编写更易于管理的代码。
这是我需要完成的一些伪代码:
// if true, the phone validation is skipped
let forceRequest = false
// true if a 3rd party web-service has checked the phone number
let isVerified = true
// true if the 3rd party checked the phone number and it is valid
var isValid = false
if !isVerified {
// update value from 3rd party web-service
isValid = isValidPhoneNumberPromise()
}
// If the phone no is invalid …Run Code Online (Sandbox Code Playgroud)