|
|
|
@ -3,74 +3,74 @@ import PromiseKit
|
|
|
|
|
public extension Thenable {
|
|
|
|
|
|
|
|
|
|
func then2<U>(_ body: @escaping (T) throws -> U) -> Promise<U.T> where U : Thenable {
|
|
|
|
|
return then(on: DispatchQueue.global(qos: .default), body)
|
|
|
|
|
return then(on: LokiAPI.workQueue, body)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func map2<U>(_ transform: @escaping (T) throws -> U) -> Promise<U> {
|
|
|
|
|
return map(on: DispatchQueue.global(qos: .default), transform)
|
|
|
|
|
return map(on: LokiAPI.workQueue, transform)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func done2(_ body: @escaping (T) throws -> Void) -> Promise<Void> {
|
|
|
|
|
return done(on: DispatchQueue.global(qos: .default), body)
|
|
|
|
|
return done(on: LokiAPI.workQueue, body)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func get2(_ body: @escaping (T) throws -> Void) -> Promise<T> {
|
|
|
|
|
return get(on: DispatchQueue.global(qos: .default), body)
|
|
|
|
|
return get(on: LokiAPI.workQueue, body)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public extension Thenable where T: Sequence {
|
|
|
|
|
|
|
|
|
|
func mapValues2<U>(_ transform: @escaping (T.Iterator.Element) throws -> U) -> Promise<[U]> {
|
|
|
|
|
return mapValues(on: DispatchQueue.global(qos: .default), transform)
|
|
|
|
|
return mapValues(on: LokiAPI.workQueue, transform)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public extension Guarantee {
|
|
|
|
|
|
|
|
|
|
func then2<U>(_ body: @escaping (T) -> Guarantee<U>) -> Guarantee<U> {
|
|
|
|
|
return then(on: DispatchQueue.global(qos: .default), body)
|
|
|
|
|
return then(on: LokiAPI.workQueue, body)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func map2<U>(_ body: @escaping (T) -> U) -> Guarantee<U> {
|
|
|
|
|
return map(on: DispatchQueue.global(qos: .default), body)
|
|
|
|
|
return map(on: LokiAPI.workQueue, body)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func done2(_ body: @escaping (T) -> Void) -> Guarantee<Void> {
|
|
|
|
|
return done(on: DispatchQueue.global(qos: .default), body)
|
|
|
|
|
return done(on: LokiAPI.workQueue, body)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func get2(_ body: @escaping (T) -> Void) -> Guarantee<T> {
|
|
|
|
|
return get(on: DispatchQueue.global(qos: .default), body)
|
|
|
|
|
return get(on: LokiAPI.workQueue, body)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public extension CatchMixin {
|
|
|
|
|
|
|
|
|
|
func catch2(_ body: @escaping (Error) -> Void) -> PMKFinalizer {
|
|
|
|
|
return self.catch(on: DispatchQueue.global(qos: .default), body)
|
|
|
|
|
return self.catch(on: LokiAPI.workQueue, body)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func recover2<U: Thenable>(_ body: @escaping(Error) throws -> U) -> Promise<T> where U.T == T {
|
|
|
|
|
return recover(on: DispatchQueue.global(qos: .default), body)
|
|
|
|
|
return recover(on: LokiAPI.workQueue, body)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func recover2(_ body: @escaping(Error) -> Guarantee<T>) -> Guarantee<T> {
|
|
|
|
|
return recover(on: DispatchQueue.global(qos: .default), body)
|
|
|
|
|
return recover(on: LokiAPI.workQueue, body)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func ensure2(_ body: @escaping () -> Void) -> Promise<T> {
|
|
|
|
|
return ensure(on: DispatchQueue.global(qos: .default), body)
|
|
|
|
|
return ensure(on: LokiAPI.workQueue, body)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public extension CatchMixin where T == Void {
|
|
|
|
|
|
|
|
|
|
func recover2(_ body: @escaping(Error) -> Void) -> Guarantee<Void> {
|
|
|
|
|
return recover(on: DispatchQueue.global(qos: .default), body)
|
|
|
|
|
return recover(on: LokiAPI.workQueue, body)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func recover2(_ body: @escaping(Error) throws -> Void) -> Promise<Void> {
|
|
|
|
|
return recover(on: DispatchQueue.global(qos: .default), body)
|
|
|
|
|
return recover(on: LokiAPI.workQueue, body)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|