|
7 | 7 |
|
8 | 8 | import Foundation |
9 | 9 |
|
10 | | -/// Manages uploads in-progress by the Mux Upload SDK. |
11 | | -/// If your ``MuxUpload`` is managed, you can get a new handle to it using ``getStartedUpload(ofFile:)`` |
| 10 | +/// Manages uploads in-progress by the Mux Upload SDK. Uploads are managed globally by default and can be started, paused, |
| 11 | +/// or cancelled from anywhere in your app. |
12 | 12 | /// |
13 | | -/// To create a new upload, use ``MuxUpload`` |
| 13 | +/// This class is used to find and resume uploads previously-created via ``MuxUpload``. Upload tasks created by ``MuxUpload`` |
| 14 | +/// are, by defauly globally managed. If your ``MuxUpload`` is managed, you can get a new handle to it anywhere by using |
| 15 | +/// ``findStartedUpload(ofFile:)`` or ``allManagedUploads()`` |
14 | 16 | /// |
| 17 | +/// ## Handling failure, backgrounding, and process death |
15 | 18 | /// Managed uploads can be resumed where they left off after process death, and can be accessed anywhere in your |
16 | | -/// app without needing to manually track the tasks or their state |
| 19 | +/// app without needing to manually track the tasks or their state. Managed uploads only survive process death if they |
| 20 | +/// were paused, in progress, or have failed. Success must be handled by you, even if it occurs, eg, during a `BGTask` |
17 | 21 | /// |
18 | | -/// Managed uploads only survive process death if they were paused or in progress. Success and failure must be handled |
19 | | -/// by you, even if those events occur during (for instance) a ``BGTask`` |
| 22 | +/// ```swift |
| 23 | +/// // Call during app init |
| 24 | +/// UploadManager.resumeAllUploads() |
| 25 | +/// let restartedUploads = UploadManager.allManagedUploads() |
| 26 | +/// // ... do something with the restrted uploads, like subscribing to progress updates for instance |
| 27 | +/// ``` |
20 | 28 | /// |
21 | | -/// (see ``MuxUpload.Builder.manage(automatically:)``) |
22 | 29 | public final class UploadManager { |
23 | 30 |
|
24 | 31 | private var uploadersByURL: [URL : ChunkedFileUploader] = [:] |
@@ -68,7 +75,7 @@ public final class UploadManager { |
68 | 75 | } |
69 | 76 |
|
70 | 77 | /// Resumes all upload that were paused or interrupted |
71 | | - /// It can be handy to call this in your ``AppDelegate`` to resume uploads that have been killed by the process dying |
| 78 | + /// It can be useful to call this during app initialization to resume uploads that have been killed by the process dying |
72 | 79 | public func resumeAllUploads() { |
73 | 80 | Task.detached { [self] in |
74 | 81 | for upload in await uploadActor.getAllUploads() { |
@@ -147,6 +154,7 @@ public final class UploadManager { |
147 | 154 |
|
148 | 155 | /// A delegate that handles changes to the list of active uploads |
149 | 156 | public protocol UploadsUpdatedDelegate: AnyObject { |
| 157 | + /// Called when the global list of uploads changes. This happens whenever a new upload is started, or an existing one completes or fails |
150 | 158 | func uploadListUpdated(with list: [MuxUpload]) |
151 | 159 | } |
152 | 160 |
|
|
0 commit comments