【发布时间】:2018-03-01 11:36:09
【问题描述】:
我想使用 PromiseKit 中的这个方法,但不知道如何编写propper synthax :x
public func firstly<U: Thenable>(execute body: () throws -> U) -> Promise<U.T> {
do {
let rp = Promise<U.T>(.pending)
try body().pipe(to: rp.box.seal)
return rp
} catch {
return Promise(error: error)
}
}
firstly {
return someMethodWhichReturnsPromise()
}.then{
}
...
我该如何调用它? 代码来自:https://github.com/mxcl/PromiseKit/blob/master/Sources/firstly.swift
【问题讨论】:
标签: ios swift promisekit