-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
369 additions
and
278 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
29 changes: 22 additions & 7 deletions
29
Examples/LocationManager/Common/LocalSearchClient/Client.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,31 @@ | ||
import ComposableArchitecture | ||
import MapKit | ||
import Dependencies | ||
|
||
extension DependencyValues { | ||
public var localSearchClient: LocalSearchClient { | ||
get { self[LocalSearchClient.self] } | ||
set { self[LocalSearchClient.self] = newValue } | ||
} | ||
} | ||
|
||
extension LocalSearchClient: TestDependencyKey { | ||
public static let previewValue = Self.noop | ||
public static let testValue = Self.failing | ||
} | ||
|
||
extension LocalSearchClient { | ||
public static let noop = Self( | ||
search: { _ in try await Task.never() } | ||
) | ||
} | ||
|
||
public struct LocalSearchClient { | ||
public var search: (MKLocalSearch.Request) -> EffectPublisher<LocalSearchResponse, Error> | ||
public var search: @Sendable (MKLocalSearch.Request) async throws -> LocalSearchResponse | ||
|
||
public init( | ||
search: @escaping (MKLocalSearch.Request) -> EffectPublisher<LocalSearchResponse, Error> | ||
search: @escaping @Sendable (MKLocalSearch.Request) async throws -> LocalSearchResponse | ||
) { | ||
self.search = search | ||
} | ||
|
||
public struct Error: Swift.Error, Equatable { | ||
public init() {} | ||
} | ||
} | ||
|
4 changes: 2 additions & 2 deletions
4
Examples/LocationManager/Common/LocalSearchClient/Failing.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import ComposableArchitecture | ||
import XCTestDynamicOverlay | ||
import MapKit | ||
|
||
extension LocalSearchClient { | ||
public static let failing = Self( | ||
search: { _ in .failing("LocalSearchClient.search") } | ||
search: { _ in unimplemented("LocalSearchClient.search") } | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.