Skip to content

Commit 6cae8ed

Browse files
committed
Add input status handler
1 parent a333b8c commit 6cae8ed

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

Sources/MuxUploadSDK/InternalUtilities/UploadInput.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ struct UploadInput {
8080
}
8181
}
8282

83+
extension UploadInput.Status: Equatable {
84+
85+
}
86+
8387
extension UploadInput {
8488
init(asset: AVAsset) {
8589
self.status = .ready(asset)

Sources/MuxUploadSDK/PublicAPI/MuxUpload.swift

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,13 @@ public typealias UploadResult = Result<MuxUpload.Success, MuxUpload.UploadError>
5050
public final class MuxUpload : Hashable, Equatable {
5151

5252
private var options: UploadOptions
53-
private var input: UploadInput
53+
private var input: UploadInput {
54+
didSet {
55+
if oldValue.status != input.status {
56+
inputStatusHandler?(inputStatus)
57+
}
58+
}
59+
}
5460

5561
private var internalStatus: UploadInput.Status {
5662
input.status
@@ -129,6 +135,16 @@ public final class MuxUpload : Hashable, Equatable {
129135
}
130136
}
131137

138+
/**
139+
Handles a change in the input status of the upload
140+
*/
141+
public typealias InputStatusHandler = (InputStatus) -> ()
142+
143+
/**
144+
If set will be notified of a change to a new input status
145+
*/
146+
public var inputStatusHandler: InputStatusHandler?
147+
132148
private let manageBySDK: Bool
133149
private let id: Int
134150

Sources/MuxUploadSDK/Upload/UploadInfo.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ struct UploadInfo : Codable {
3434
var optOutOfEventTracking: Bool
3535
}
3636

37+
extension UploadInfo: Equatable {
38+
39+
}
40+
3741
extension UploadInfo {
3842

3943
init(

0 commit comments

Comments
 (0)