Skip to content

Commit 4558963

Browse files
committed
Add canceller parameter for on(success:failure:).
1 parent c333c7d commit 4558963

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

SwiftTask/SwiftTask.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,11 +547,16 @@ public class Task<Progress, Value, Error>: Cancellable, CustomStringConvertible
547547
}
548548

549549
public func on(success success: Value -> Void = { _ in }, failure: ErrorInfo -> Void = { _ in }) -> Self
550+
{
551+
var dummyCanceller: Canceller? = nil
552+
return self.on(&dummyCanceller, success: success, failure: failure)
553+
}
554+
555+
public func on<C: Canceller>(inout canceller: C?, success: Value -> Void = { _ in }, failure: ErrorInfo -> Void = { _ in }) -> Self
550556
{
551557
let selfMachine = self._machine
552558

553-
var dummyCanceller: Canceller? = nil
554-
self._then(&dummyCanceller) {
559+
self._then(&canceller) {
555560
if let value = selfMachine.value.rawValue {
556561
success(value)
557562
}

0 commit comments

Comments
 (0)