@@ -296,7 +296,7 @@ public class Task<Progress, Value, Error>
296
296
/// then (fulfilled & rejected) + closure returning task
297
297
public func then< Progress2, Value2> ( thenClosure: ( Value ? , ErrorInfo ? ) -> Task < Progress2 , Value2 , Error > ) -> Task < Progress2 , Value2 , Error >
298
298
{
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
300
300
301
301
let bind = { ( value: Value ? , errorInfo: ErrorInfo ? ) -> Void in
302
302
let innerTask = thenClosure ( value, errorInfo)
@@ -326,24 +326,22 @@ public class Task<Progress, Value, Error>
326
326
configure. cancel = { innerTask. cancel ( ) ; return }
327
327
}
328
328
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 )
340
338
}
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 )
345
343
}
346
- }
344
+ }
347
345
}
348
346
349
347
}
@@ -362,7 +360,7 @@ public class Task<Progress, Value, Error>
362
360
/// success (fulfilled) + closure returning task
363
361
public func success< Progress2, Value2> ( successClosure: Value -> Task < Progress2 , Value2 , Error > ) -> Task < Progress2 , Value2 , Error >
364
362
{
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
366
364
367
365
let bind = { ( value: Value ) -> Void in
368
366
let innerTask = successClosure ( value)
@@ -381,24 +379,22 @@ public class Task<Progress, Value, Error>
381
379
configure. cancel = { innerTask. cancel ( ) ; return }
382
380
}
383
381
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)
395
391
}
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 )
400
396
}
401
- }
397
+ }
402
398
}
403
399
404
400
}
@@ -417,7 +413,7 @@ public class Task<Progress, Value, Error>
417
413
/// failure (rejected) + closure returning task
418
414
public func failure( failureClosure: ErrorInfo -> Task ) -> Task
419
415
{
420
- let newTask = Task { [ weak self ] ( progress, fulfill, _reject: _RejectHandler , configure) in
416
+ let newTask = Task { ( progress, fulfill, _reject: _RejectHandler , configure) in
421
417
422
418
let bind = { ( errorInfo: ErrorInfo ) -> Void in
423
419
let innerTask = failureClosure ( errorInfo)
@@ -436,25 +432,23 @@ public class Task<Progress, Value, Error>
436
432
configure. cancel = { innerTask. cancel ( ) ; return }
437
433
}
438
434
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)
451
445
}
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 )
456
450
}
457
- }
451
+ }
458
452
}
459
453
460
454
}
0 commit comments