Skip to content

Commit 59045db

Browse files
Add missing JSON getters to LiveMapValue
Missed this in cb9a11c.
1 parent 9bae7f3 commit 59045db

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Sources/AblyLiveObjects/Public/PublicTypes.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,22 @@ public enum LiveMapValue: Sendable, Equatable {
143143
return nil
144144
}
145145

146+
/// If this `LiveMapValue` has case `jsonArray`, this returns the associated value. Else, it returns `nil`.
147+
public var jsonArrayValue: [JSONValue]? {
148+
if case let .jsonArray(value) = self {
149+
return value
150+
}
151+
return nil
152+
}
153+
154+
/// If this `LiveMapValue` has case `jsonObject`, this returns the associated value. Else, it returns `nil`.
155+
public var jsonObjectValue: [String: JSONValue]? {
156+
if case let .jsonObject(value) = self {
157+
return value
158+
}
159+
return nil
160+
}
161+
146162
// MARK: - Equatable Implementation
147163

148164
public static func == (lhs: LiveMapValue, rhs: LiveMapValue) -> Bool {

0 commit comments

Comments
 (0)