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