我是PromiseKit的新手,但是我不能得到一些非常基本的工作。考虑到这一点:
func test1() -> Promise<Bool> {
return Promise<Bool>.value(true)
}
func test2() -> Promise<Bool> {
return Promise<Bool> { seal in
seal.fulfill(true)
}
}
func test3() -> Promise<Bool> {
return Promise<Bool>.value(true)
}下面给出了每一行的错误:
无法将
Promise<Bool>类型的值转换为闭包结果类型Guarantee<()>
firstly {
test1()
}.then {
test2()
}.then {
test3()
}.done {
}.catch {
}我做错了什么?我一直在尝试各种组合,但似乎没有什么效果。我上PromiseKit 6.13了。
发布于 2020-03-30 05:36:20
从PromiseKit故障排除指南中获取
Swift不允许您忽略闭包的参数。
因此,您必须只使用指定闭包参数,如下所示:
firstly {
test1()
}.then { boolValue in
self.test2()
}.then { boolValue in
self.test3()
}.done { _ in
}.catch { _ in
}或者即使将_名称分配给参数(确认参数存在但忽略它的名称)
firstly {
test1()
}.then { _ in
self.test2()
}.then { _ in
self.test3()
}.done { _ in
}.catch { _ in
}https://stackoverflow.com/questions/60924297
复制相似问题