Skip to content

Commit

Permalink
Merge pull request #29 from klop/master
Browse files Browse the repository at this point in the history
No longer creating additional promise in tap version of then
  • Loading branch information
khanlou authored Nov 16, 2017
2 parents f5b2821 + cf14c4a commit 8e65671
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions Promise/Promise.swift
Original file line number Diff line number Diff line change
Expand Up @@ -185,19 +185,7 @@ public final class Promise<Value> {

@discardableResult
public func then(on queue: ExecutionContext = DispatchQueue.main, _ onFulfilled: @escaping (Value) -> (), _ onRejected: @escaping (Error) -> () = { _ in }) -> Promise<Value> {
_ = Promise<Value>(work: { fulfill, reject in
self.addCallbacks(
on: queue,
onFulfilled: { value in
fulfill(value)
onFulfilled(value)
},
onRejected: { error in
reject(error)
onRejected(error)
}
)
})
addCallbacks(on: queue, onFulfilled: onFulfilled, onRejected: onRejected)
return self
}

Expand Down

0 comments on commit 8e65671

Please sign in to comment.