Skip to content

Commit 79476c8

Browse files
committed
Update to only enforce decodable types for use with return objects
1 parent ea85e43 commit 79476c8

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Sources/ComposableArchitecturePattern/Server+API.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Foundation
99

1010
/// An object that specifies a specific server API.
1111
///
12-
/// - Note: It is highly encouraged to define your `supportedReturnObjects` to ensure `-supports<T: Codable>(_:)` is able to automatically verify against this.
12+
/// - Note: It is highly encouraged to define your `supportedReturnObjects` to ensure `-supports<T: Decodable>(_:)` is able to automatically verify against this.
1313
public protocol ServerAPI: Identifiable, Equatable {
1414
/// The environment this API should be used against. Default is `nil`.
1515
/// - Note: If it can be used against any environment, leave it `nil`.
@@ -33,7 +33,7 @@ public protocol ServerAPI: Identifiable, Equatable {
3333
/// All the return objects this API supports. Default is `nil`.
3434
///
3535
/// This helps ensure a non-supported object isn't attempted to be used with the API.
36-
var supportedReturnObjects: [Codable.Type]? { get }
36+
var supportedReturnObjects: [Decodable.Type]? { get }
3737

3838
/// The timeout length for the request. Default is `60`.
3939
var timeoutInterval: TimeInterval { get }
@@ -49,8 +49,9 @@ public protocol ServerAPI: Identifiable, Equatable {
4949
func supports<T: Decodable>(_ object: T.Type) -> Bool
5050
}
5151

52-
extension Sequence where Element == Codable.Type {
53-
func isEqual(to other: [Codable.Type]) -> Bool {
52+
extension Sequence where Element == Decodable.Type {
53+
/// Whether the given collection of decodable types is equal to this collection of decodable types.
54+
func isEqual(to other: [Decodable.Type]) -> Bool {
5455
self.contains(where: { type in other.contains(where: { $0 == type }) })
5556
}
5657
}
@@ -90,7 +91,7 @@ public extension ServerAPI {
9091

9192
var body: Data? { nil }
9293

93-
var supportedReturnObjects: [Codable.Type]? { nil }
94+
var supportedReturnObjects: [Decodable.Type]? { nil }
9495

9596
var timeoutInterval: TimeInterval { 60 }
9697

0 commit comments

Comments
 (0)