You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: SwiftTask/SwiftTask.swift
+71-28Lines changed: 71 additions & 28 deletions
Original file line number
Diff line number
Diff line change
@@ -111,45 +111,64 @@ public class Task<Progress, Value, Error>
111
111
returnself.machine.state
112
112
}
113
113
114
-
publicconvenienceinit(closure:PromiseInitClosure)
114
+
///
115
+
/// Creates new task.
116
+
/// e.g. Task<P, V, E>(weakified: false) { (progress, fulfill, reject, configure) in ... }
117
+
///
118
+
/// :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.
119
+
///
120
+
/// :param: initClosure e.g. { (progress, fulfill, reject, configure) in ... }. fulfill(value) and reject(error) handlers must be called inside this closure, where calling progress(progressValue) handler is optional. Also as options, configure.pause/resume/cancel closures can be set to gain control from outside e.g. task.pause()/resume()/cancel(). When using configure, make sure to use weak modifier when appropriate to avoid "task -> player" retaining which often causes retain cycle.
0 commit comments