Skip to content

Commit bdf910d

Browse files
committed
Remove unnecessary '[weak self]'.
1 parent 92b83d6 commit bdf910d

File tree

1 file changed

+46
-52
lines changed

1 file changed

+46
-52
lines changed

SwiftTask/SwiftTask.swift

Lines changed: 46 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ public class Task<Progress, Value, Error>
296296
/// then (fulfilled & rejected) + closure returning task
297297
public func then<Progress2, Value2>(thenClosure: (Value?, ErrorInfo?) -> Task<Progress2, Value2, Error>) -> Task<Progress2, Value2, Error>
298298
{
299-
let newTask = Task<Progress2, Value2, Error> { [weak self] (progress, fulfill, _reject: _RejectHandler, configure) in
299+
let newTask = Task<Progress2, Value2, Error> { (progress, fulfill, _reject: _RejectHandler, configure) in
300300

301301
let bind = { (value: Value?, errorInfo: ErrorInfo?) -> Void in
302302
let innerTask = thenClosure(value, errorInfo)
@@ -326,24 +326,22 @@ public class Task<Progress, Value, Error>
326326
configure.cancel = { innerTask.cancel(); return }
327327
}
328328

329-
if let self_ = self {
330-
switch self_.machine.state {
331-
case .Fulfilled:
332-
bind(self_.value!, nil)
333-
case .Rejected:
334-
bind(nil, self_.errorInfo!)
335-
default:
336-
self_.machine.addEventHandler(.Fulfill) { context in
337-
if let value = context.userInfo as? Value {
338-
bind(value, nil)
339-
}
329+
switch self.machine.state {
330+
case .Fulfilled:
331+
bind(self.value!, nil)
332+
case .Rejected:
333+
bind(nil, self.errorInfo!)
334+
default:
335+
self.machine.addEventHandler(.Fulfill) { context in
336+
if let value = context.userInfo as? Value {
337+
bind(value, nil)
340338
}
341-
self_.machine.addEventHandler(.Reject) { context in
342-
if let errorInfo = context.userInfo as? ErrorInfo {
343-
bind(nil, errorInfo)
344-
}
339+
}
340+
self.machine.addEventHandler(.Reject) { context in
341+
if let errorInfo = context.userInfo as? ErrorInfo {
342+
bind(nil, errorInfo)
345343
}
346-
}
344+
}
347345
}
348346

349347
}
@@ -362,7 +360,7 @@ public class Task<Progress, Value, Error>
362360
/// success (fulfilled) + closure returning task
363361
public func success<Progress2, Value2>(successClosure: Value -> Task<Progress2, Value2, Error>) -> Task<Progress2, Value2, Error>
364362
{
365-
let newTask = Task<Progress2, Value2, Error> { [weak self] (progress, fulfill, _reject: _RejectHandler, configure) in
363+
let newTask = Task<Progress2, Value2, Error> { (progress, fulfill, _reject: _RejectHandler, configure) in
366364

367365
let bind = { (value: Value) -> Void in
368366
let innerTask = successClosure(value)
@@ -381,24 +379,22 @@ public class Task<Progress, Value, Error>
381379
configure.cancel = { innerTask.cancel(); return }
382380
}
383381

384-
if let self_ = self {
385-
switch self_.machine.state {
386-
case .Fulfilled:
387-
bind(self_.value!)
388-
case .Rejected:
389-
_reject(self_.errorInfo!)
390-
default:
391-
self_.machine.addEventHandler(.Fulfill) { context in
392-
if let value = context.userInfo as? Value {
393-
bind(value)
394-
}
382+
switch self.machine.state {
383+
case .Fulfilled:
384+
bind(self.value!)
385+
case .Rejected:
386+
_reject(self.errorInfo!)
387+
default:
388+
self.machine.addEventHandler(.Fulfill) { context in
389+
if let value = context.userInfo as? Value {
390+
bind(value)
395391
}
396-
self_.machine.addEventHandler(.Reject) { context in
397-
if let errorInfo = context.userInfo as? ErrorInfo {
398-
_reject(errorInfo)
399-
}
392+
}
393+
self.machine.addEventHandler(.Reject) { context in
394+
if let errorInfo = context.userInfo as? ErrorInfo {
395+
_reject(errorInfo)
400396
}
401-
}
397+
}
402398
}
403399

404400
}
@@ -417,7 +413,7 @@ public class Task<Progress, Value, Error>
417413
/// failure (rejected) + closure returning task
418414
public func failure(failureClosure: ErrorInfo -> Task) -> Task
419415
{
420-
let newTask = Task { [weak self] (progress, fulfill, _reject: _RejectHandler, configure) in
416+
let newTask = Task { (progress, fulfill, _reject: _RejectHandler, configure) in
421417

422418
let bind = { (errorInfo: ErrorInfo) -> Void in
423419
let innerTask = failureClosure(errorInfo)
@@ -436,25 +432,23 @@ public class Task<Progress, Value, Error>
436432
configure.cancel = { innerTask.cancel(); return}
437433
}
438434

439-
if let self_ = self {
440-
switch self_.machine.state {
441-
case .Fulfilled:
442-
fulfill(self_.value!)
443-
case .Rejected:
444-
let errorInfo = self_.errorInfo!
445-
bind(errorInfo)
446-
default:
447-
self_.machine.addEventHandler(.Fulfill) { context in
448-
if let value = context.userInfo as? Value {
449-
fulfill(value)
450-
}
435+
switch self.machine.state {
436+
case .Fulfilled:
437+
fulfill(self.value!)
438+
case .Rejected:
439+
let errorInfo = self.errorInfo!
440+
bind(errorInfo)
441+
default:
442+
self.machine.addEventHandler(.Fulfill) { context in
443+
if let value = context.userInfo as? Value {
444+
fulfill(value)
451445
}
452-
self_.machine.addEventHandler(.Reject) { context in
453-
if let errorInfo = context.userInfo as? ErrorInfo {
454-
bind(errorInfo)
455-
}
446+
}
447+
self.machine.addEventHandler(.Reject) { context in
448+
if let errorInfo = context.userInfo as? ErrorInfo {
449+
bind(errorInfo)
456450
}
457-
}
451+
}
458452
}
459453

460454
}

0 commit comments

Comments
 (0)