Skip to content

Commit 800cd71

Browse files
committed
Fix progressHandler which should not capture task due to its characteristic.
1 parent a2148e1 commit 800cd71

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

SwiftTask/SwiftTask.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,10 @@ public class Task<Progress, Value, Error>
195195
configuration.clear()
196196
}
197197

198-
let progressHandler: ProgressHandler = { /*[weak self]*/ (progress: Progress) in
199-
self.machine <-! (.Progress, progress) // NOTE: capture self
200-
return
198+
let progressHandler: ProgressHandler = { [weak self] (progress: Progress) in
199+
if let self_ = self {
200+
self_.machine <-! (.Progress, progress)
201+
}
201202
}
202203

203204
let fulfillHandler: FulFillHandler = { /*[weak self]*/ (value: Value) in

0 commit comments

Comments
 (0)