Skip to content

Commit 6ef98f0

Browse files
committed
Add method comments.
1 parent 113dae4 commit 6ef98f0

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

SwiftTask/SwiftTask.swift

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ public class Task<Progress, Value, Error>: _Task<Error>
127127

128128
///
129129
/// Creates new task.
130-
/// e.g. Task<P, V, E>(weakified: false) { progress, fulfill, reject, configure in ... }
130+
///
131+
/// - e.g. Task<P, V, E>(weakified: false) { progress, fulfill, reject, configure in ... }
131132
///
132133
/// :param: weakified Weakifies progress/fulfill/reject handlers to let player (inner asynchronous implementation inside initClosure) NOT CAPTURE this created new task. Normally, weakified = false should be set to gain "player -> task" retaining, so that task will be automatically deinited when player is deinited. If weakified = true, task must be manually retained somewhere else, or it will be immediately deinited.
133134
///
@@ -364,6 +365,11 @@ public class Task<Progress, Value, Error>: _Task<Error>
364365
return nextTask!
365366
}
366367

368+
///
369+
/// Add progress handler delivered from `initClosure`'s `progress()` argument.
370+
///
371+
/// - e.g. task.progress { oldProgress, newProgress in ... }
372+
///
367373
public func progress(progressClosure: ProgressTuple -> Void) -> Task
368374
{
369375
self.machine.addEventHandler(.Progress) { [weak self] context in
@@ -375,15 +381,23 @@ public class Task<Progress, Value, Error>: _Task<Error>
375381
return self
376382
}
377383

384+
///
378385
/// then (fulfilled & rejected) + closure returning value
386+
///
387+
/// - e.g. task.then { value, errorInfo -> NextValueType in ... }
388+
///
379389
public func then<Value2>(thenClosure: (Value?, ErrorInfo?) -> Value2) -> Task<Progress, Value2, Error>
380390
{
381391
return self.then { (value: Value?, errorInfo: ErrorInfo?) -> Task<Progress, Value2, Error> in
382392
return Task<Progress, Value2, Error>(value: thenClosure(value, errorInfo))
383393
}
384394
}
385395

396+
///
386397
/// then (fulfilled & rejected) + closure returning task
398+
///
399+
/// - e.g. task.then { value, errorInfo -> NextTaskType in ... }
400+
///
387401
public func then<Progress2, Value2>(thenClosure: (Value?, ErrorInfo?) -> Task<Progress2, Value2, Error>) -> Task<Progress2, Value2, Error>
388402
{
389403
let newTask = Task<Progress2, Value2, Error> { machine, progress, fulfill, _reject, configure in
@@ -459,15 +473,23 @@ public class Task<Progress, Value, Error>: _Task<Error>
459473
return newTask
460474
}
461475

476+
///
462477
/// success (fulfilled) + closure returning value
478+
///
479+
/// - e.g. task.success { value -> NextValueType in ... }
480+
///
463481
public func success<Value2>(successClosure: Value -> Value2) -> Task<Progress, Value2, Error>
464482
{
465483
return self.success { (value: Value) -> Task<Progress, Value2, Error> in
466484
return Task<Progress, Value2, Error>(value: successClosure(value))
467485
}
468486
}
469487

488+
///
470489
/// success (fulfilled) + closure returning task
490+
///
491+
/// - e.g. task.success { value -> NextTaskType in ... }
492+
///
471493
public func success<Progress2, Value2>(successClosure: Value -> Task<Progress2, Value2, Error>) -> Task<Progress2, Value2, Error>
472494
{
473495
let newTask = Task<Progress2, Value2, Error> { machine, progress, fulfill, _reject, configure in
@@ -529,15 +551,25 @@ public class Task<Progress, Value, Error>: _Task<Error>
529551
return newTask
530552
}
531553

554+
///
532555
/// failure (rejected) + closure returning value
556+
///
557+
/// - e.g. task.failure { errorInfo -> NextValueType in ... }
558+
/// - e.g. task.failure { error, isCancelled -> NextValueType in ... }
559+
///
533560
public func failure(failureClosure: ErrorInfo -> Value) -> Task
534561
{
535562
return self.failure { (errorInfo: ErrorInfo) -> Task in
536563
return Task(value: failureClosure(errorInfo))
537564
}
538565
}
539566

567+
///
540568
/// failure (rejected) + closure returning task
569+
///
570+
/// - e.g. task.failure { errorInfo -> NextTaskType in ... }
571+
/// - e.g. task.failure { error, isCancelled -> NextTaskType in ... }
572+
///
541573
public func failure(failureClosure: ErrorInfo -> Task) -> Task
542574
{
543575
let newTask = Task { machine, progress, fulfill, _reject, configure in

0 commit comments

Comments
 (0)