diff --git a/Package.resolved b/Package.resolved index 87e4e57..e748480 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,102 +1,12 @@ { "pins" : [ - { - "identity" : "combine-schedulers", - "kind" : "remoteSourceControl", - "location" : "https://github.com/pointfreeco/combine-schedulers", - "state" : { - "revision" : "ec62f32d21584214a4b27c8cee2b2ad70ab2c38a", - "version" : "0.11.0" - } - }, - { - "identity" : "swift-case-paths", - "kind" : "remoteSourceControl", - "location" : "https://github.com/pointfreeco/swift-case-paths", - "state" : { - "revision" : "fc45e7b2cfece9dd80b5a45e6469ffe67fe67984", - "version" : "0.14.1" - } - }, - { - "identity" : "swift-clocks", - "kind" : "remoteSourceControl", - "location" : "https://github.com/pointfreeco/swift-clocks", - "state" : { - "revision" : "0fbaebfc013715dab44d715a4d350ba37f297e4d", - "version" : "0.4.0" - } - }, - { - "identity" : "swift-collections", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-collections", - "state" : { - "revision" : "937e904258d22af6e447a0b72c0bc67583ef64a2", - "version" : "1.0.4" - } - }, - { - "identity" : "swift-composable-architecture", - "kind" : "remoteSourceControl", - "location" : "https://github.com/pointfreeco/swift-composable-architecture", - "state" : { - "revision" : "9f4202ab5b8422aa90f0ed983bf7652c3af7abf0", - "version" : "0.59.0" - } - }, - { - "identity" : "swift-concurrency-extras", - "kind" : "remoteSourceControl", - "location" : "https://github.com/pointfreeco/swift-concurrency-extras", - "state" : { - "revision" : "479750bd98fac2e813fffcf2af0728b5b0085795", - "version" : "0.1.1" - } - }, - { - "identity" : "swift-custom-dump", - "kind" : "remoteSourceControl", - "location" : "https://github.com/pointfreeco/swift-custom-dump", - "state" : { - "revision" : "4a87bb75be70c983a9548597e8783236feb3401e", - "version" : "0.11.1" - } - }, - { - "identity" : "swift-dependencies", - "kind" : "remoteSourceControl", - "location" : "https://github.com/pointfreeco/swift-dependencies", - "state" : { - "revision" : "16fd42ae04c6e7f74a6a86395d04722c641cccee", - "version" : "0.6.0" - } - }, - { - "identity" : "swift-identified-collections", - "kind" : "remoteSourceControl", - "location" : "https://github.com/pointfreeco/swift-identified-collections", - "state" : { - "revision" : "d01446a78fb768adc9a78cbb6df07767c8ccfc29", - "version" : "0.8.0" - } - }, - { - "identity" : "swiftui-navigation", - "kind" : "remoteSourceControl", - "location" : "https://github.com/pointfreeco/swiftui-navigation", - "state" : { - "revision" : "2aa885e719087ee19df251c08a5980ad3e787f12", - "version" : "0.8.0" - } - }, { "identity" : "xctest-dynamic-overlay", "kind" : "remoteSourceControl", - "location" : "https://github.com/pointfreeco/xctest-dynamic-overlay", + "location" : "https://github.com/pointfreeco/xctest-dynamic-overlay.git", "state" : { - "revision" : "50843cbb8551db836adec2290bb4bc6bac5c1865", - "version" : "0.9.0" + "revision" : "23cbf2294e350076ea4dbd7d5d047c1e76b03631", + "version" : "1.0.2" } } ], diff --git a/Package.swift b/Package.swift index ba7336a..d89ccde 100644 --- a/Package.swift +++ b/Package.swift @@ -18,14 +18,15 @@ let package = Package( ], dependencies: [ .package( - url: "https://github.com/pointfreeco/swift-composable-architecture", - .upToNextMajor(from: "0.43.0")) + url: "https://github.com/pointfreeco/xctest-dynamic-overlay", + "0.9.0"..<"2.0.0" + ), ], targets: [ .target( name: "ComposableCoreLocation", dependencies: [ - .product(name: "ComposableArchitecture", package: "swift-composable-architecture") + .product(name: "XCTestDynamicOverlay", package: "xctest-dynamic-overlay"), ] ), .testTarget( diff --git a/Sources/ComposableCoreLocation/Failing.swift b/Sources/ComposableCoreLocation/Failing.swift index 4077b02..a69f57b 100644 --- a/Sources/ComposableCoreLocation/Failing.swift +++ b/Sources/ComposableCoreLocation/Failing.swift @@ -1,4 +1,4 @@ -import ComposableArchitecture +import Combine import CoreLocation import XCTestDynamicOverlay @@ -46,9 +46,9 @@ extension LocationManager { XCTFail("A failing endpoint was accessed: 'LocationManager.authorizationStatus'") return .notDetermined }, - delegate: { .failing("LocationManager.delegate") }, + delegate: { .unimplemented("LocationManager.delegate") }, dismissHeadingCalibrationDisplay: { - .failing("LocationManager.dismissHeadingCalibrationDisplay") + .unimplemented("LocationManager.dismissHeadingCalibrationDisplay") }, heading: { XCTFail("A failing endpoint was accessed: 'LocationManager.heading'") @@ -78,32 +78,32 @@ extension LocationManager { XCTFail("A failing endpoint was accessed: 'LocationManager.monitoredRegions'") return [] }, - requestAlwaysAuthorization: { .failing("LocationManager.requestAlwaysAuthorization") }, - requestLocation: { .failing("LocationManager.requestLocation") }, + requestAlwaysAuthorization: { .unimplemented("LocationManager.requestAlwaysAuthorization") }, + requestLocation: { .unimplemented("LocationManager.requestLocation") }, requestWhenInUseAuthorization: { - .failing("LocationManager.requestWhenInUseAuthorization") + .unimplemented("LocationManager.requestWhenInUseAuthorization") }, requestTemporaryFullAccuracyAuthorization: { _ in - .failing("LocationManager.requestTemporaryFullAccuracyAuthorization") + .unimplemented("LocationManager.requestTemporaryFullAccuracyAuthorization") }, - set: { _ in .failing("LocationManager.set") }, + set: { _ in .unimplemented("LocationManager.set") }, significantLocationChangeMonitoringAvailable: { XCTFail() return false }, - startMonitoringForRegion: { _ in .failing("LocationManager.startMonitoringForRegion") }, + startMonitoringForRegion: { _ in .unimplemented("LocationManager.startMonitoringForRegion") }, startMonitoringSignificantLocationChanges: { - .failing("LocationManager.startMonitoringSignificantLocationChanges") + .unimplemented("LocationManager.startMonitoringSignificantLocationChanges") }, - startMonitoringVisits: { .failing("LocationManager.startMonitoringVisits") }, - startUpdatingHeading: { .failing("LocationManager.startUpdatingHeading") }, - startUpdatingLocation: { .failing("LocationManager.startUpdatingLocation") }, - stopMonitoringForRegion: { _ in .failing("LocationManager.stopMonitoringForRegion") }, + startMonitoringVisits: { .unimplemented("LocationManager.startMonitoringVisits") }, + startUpdatingHeading: { .unimplemented("LocationManager.startUpdatingHeading") }, + startUpdatingLocation: { .unimplemented("LocationManager.startUpdatingLocation") }, + stopMonitoringForRegion: { _ in .unimplemented("LocationManager.stopMonitoringForRegion") }, stopMonitoringSignificantLocationChanges: { - .failing("LocationManager.stopMonitoringSignificantLocationChanges") + .unimplemented("LocationManager.stopMonitoringSignificantLocationChanges") }, - stopMonitoringVisits: { .failing("LocationManager.stopMonitoringVisits") }, - stopUpdatingHeading: { .failing("LocationManager.stopUpdatingHeading") }, - stopUpdatingLocation: { .failing("LocationManager.stopUpdatingLocation") } + stopMonitoringVisits: { .unimplemented("LocationManager.stopMonitoringVisits") }, + stopUpdatingHeading: { .unimplemented("LocationManager.stopUpdatingHeading") }, + stopUpdatingLocation: { .unimplemented("LocationManager.stopUpdatingLocation") } ) } diff --git a/Sources/ComposableCoreLocation/Interface.swift b/Sources/ComposableCoreLocation/Interface.swift index 7895e27..e8880e4 100644 --- a/Sources/ComposableCoreLocation/Interface.swift +++ b/Sources/ComposableCoreLocation/Interface.swift @@ -1,5 +1,4 @@ import Combine -import ComposableArchitecture import CoreLocation /// A wrapper around Core Location's `CLLocationManager` that exposes its functionality through @@ -257,9 +256,9 @@ public struct LocationManager { public var authorizationStatus: () -> CLAuthorizationStatus - public var delegate: () -> EffectPublisher + public var delegate: () -> AnyPublisher - public var dismissHeadingCalibrationDisplay: () -> EffectPublisher + public var dismissHeadingCalibrationDisplay: () -> AnyPublisher public var heading: () -> Heading? @@ -275,37 +274,37 @@ public struct LocationManager { public var monitoredRegions: () -> Set - public var requestAlwaysAuthorization: () -> EffectPublisher + public var requestAlwaysAuthorization: () -> AnyPublisher - public var requestLocation: () -> EffectPublisher + public var requestLocation: () -> AnyPublisher - public var requestWhenInUseAuthorization: () -> EffectPublisher + public var requestWhenInUseAuthorization: () -> AnyPublisher - public var requestTemporaryFullAccuracyAuthorization: (String) -> EffectPublisher + public var requestTemporaryFullAccuracyAuthorization: (String) -> AnyPublisher - public var set: (Properties) -> EffectPublisher + public var set: (Properties) -> AnyPublisher public var significantLocationChangeMonitoringAvailable: () -> Bool - public var startMonitoringForRegion: (Region) -> EffectPublisher + public var startMonitoringForRegion: (Region) -> AnyPublisher - public var startMonitoringSignificantLocationChanges: () -> EffectPublisher + public var startMonitoringSignificantLocationChanges: () -> AnyPublisher - public var startMonitoringVisits: () -> EffectPublisher + public var startMonitoringVisits: () -> AnyPublisher - public var startUpdatingHeading: () -> EffectPublisher + public var startUpdatingHeading: () -> AnyPublisher - public var startUpdatingLocation: () -> EffectPublisher + public var startUpdatingLocation: () -> AnyPublisher - public var stopMonitoringForRegion: (Region) -> EffectPublisher + public var stopMonitoringForRegion: (Region) -> AnyPublisher - public var stopMonitoringSignificantLocationChanges: () -> EffectPublisher + public var stopMonitoringSignificantLocationChanges: () -> AnyPublisher - public var stopMonitoringVisits: () -> EffectPublisher + public var stopMonitoringVisits: () -> AnyPublisher - public var stopUpdatingHeading: () -> EffectPublisher + public var stopUpdatingHeading: () -> AnyPublisher - public var stopUpdatingLocation: () -> EffectPublisher + public var stopUpdatingLocation: () -> AnyPublisher /// Updates the given properties of a uniquely identified `CLLocationManager`. public func set( @@ -317,9 +316,9 @@ public struct LocationManager { headingOrientation: CLDeviceOrientation? = nil, pausesLocationUpdatesAutomatically: Bool? = nil, showsBackgroundLocationIndicator: Bool? = nil - ) -> EffectPublisher { + ) -> AnyPublisher { #if os(macOS) || os(tvOS) || os(watchOS) - return .none + return Empty().eraseToAnyPublisher() #else return self.set( Properties( @@ -340,7 +339,7 @@ public struct LocationManager { extension LocationManager { public struct Properties: Equatable { var activityType: CLActivityType? = nil - + var allowsBackgroundLocationUpdates: Bool? = nil var desiredAccuracy: CLLocationAccuracy? = nil diff --git a/Sources/ComposableCoreLocation/Internal/Deprecations.swift b/Sources/ComposableCoreLocation/Internal/Deprecations.swift deleted file mode 100644 index 9bab30a..0000000 --- a/Sources/ComposableCoreLocation/Internal/Deprecations.swift +++ /dev/null @@ -1,128 +0,0 @@ -// NB: Deprecated after 0.1.0: - -#if DEBUG - extension LocationManager { - @available( - *, deprecated, - message: - "Use 'Effect.cancellable' and 'Effect.cancel' to manage the lifecycle of 'LocationManager.delegate'" - ) - public func create(id: AnyHashable) -> EffectPublisher { - self.delegate().cancellable(id: id) - } - - @available( - *, deprecated, - message: - "Use 'Effect.cancellable' and 'Effect.cancel' to manage the lifecycle of 'LocationManager.delegate'" - ) - public func destroy(id: AnyHashable) -> EffectPublisher { - .cancel(id: id) - } - - @available(*, unavailable, message: "Use 'LocationManager.failing', instead") - public static func unimplemented( - accuracyAuthorization: @escaping (AnyHashable) -> AccuracyAuthorization? = { _ in - _unimplemented("accuracyAuthorization") - }, - authorizationStatus: @escaping () -> CLAuthorizationStatus = { - _unimplemented("authorizationStatus") - }, - create: @escaping (_ id: AnyHashable) -> EffectPublisher = { _ in - _unimplemented("create") - }, - destroy: @escaping (AnyHashable) -> EffectPublisher = { _ in - _unimplemented("destroy") - }, - dismissHeadingCalibrationDisplay: @escaping (AnyHashable) -> EffectPublisher = { - _ in - _unimplemented("dismissHeadingCalibrationDisplay") - }, - heading: @escaping (AnyHashable) -> Heading? = { _ in _unimplemented("heading") }, - headingAvailable: @escaping () -> Bool = { _unimplemented("headingAvailable") }, - isRangingAvailable: @escaping () -> Bool = { _unimplemented("isRangingAvailable") }, - location: @escaping (AnyHashable) -> Location? = { _ in _unimplemented("location") }, - locationServicesEnabled: @escaping () -> Bool = { _unimplemented("locationServicesEnabled") }, - maximumRegionMonitoringDistance: @escaping (AnyHashable) -> CLLocationDistance = { _ in - _unimplemented("maximumRegionMonitoringDistance") - }, - monitoredRegions: @escaping (AnyHashable) -> Set = { _ in - _unimplemented("monitoredRegions") - }, - requestAlwaysAuthorization: @escaping (AnyHashable) -> EffectPublisher = { _ in - _unimplemented("requestAlwaysAuthorization") - }, - requestLocation: @escaping (AnyHashable) -> EffectPublisher = { _ in - _unimplemented("requestLocation") - }, - requestWhenInUseAuthorization: @escaping (AnyHashable) -> EffectPublisher = { - _ in - _unimplemented("requestWhenInUseAuthorization") - }, - requestTemporaryFullAccuracyAuthorization: @escaping (AnyHashable, String) -> EffectPublisher< - Never, Never - > = { _, _ in - _unimplemented("requestTemporaryFullAccuracyAuthorization") - }, - set: @escaping (_ id: AnyHashable, _ properties: Properties) -> EffectPublisher< - Never, Never - > = { - _, _ in _unimplemented("set") - }, - significantLocationChangeMonitoringAvailable: @escaping () -> Bool = { - _unimplemented("significantLocationChangeMonitoringAvailable") - }, - startMonitoringSignificantLocationChanges: @escaping (AnyHashable) -> EffectPublisher< - Never, Never - > = { - _ in _unimplemented("startMonitoringSignificantLocationChanges") - }, - startMonitoringForRegion: @escaping (AnyHashable, Region) -> EffectPublisher = { - _, _ in - _unimplemented("startMonitoringForRegion") - }, - startMonitoringVisits: @escaping (AnyHashable) -> EffectPublisher = { _ in - _unimplemented("startMonitoringVisits") - }, - startUpdatingLocation: @escaping (AnyHashable) -> EffectPublisher = { _ in - _unimplemented("startUpdatingLocation") - }, - stopMonitoringSignificantLocationChanges: @escaping (AnyHashable) -> EffectPublisher< - Never, Never - > = { - _ in _unimplemented("stopMonitoringSignificantLocationChanges") - }, - stopMonitoringForRegion: @escaping (AnyHashable, Region) -> EffectPublisher = { - _, _ in - _unimplemented("stopMonitoringForRegion") - }, - stopMonitoringVisits: @escaping (AnyHashable) -> EffectPublisher = { _ in - _unimplemented("stopMonitoringVisits") - }, - startUpdatingHeading: @escaping (AnyHashable) -> EffectPublisher = { _ in - _unimplemented("startUpdatingHeading") - }, - stopUpdatingHeading: @escaping (AnyHashable) -> EffectPublisher = { _ in - _unimplemented("stopUpdatingHeading") - }, - stopUpdatingLocation: @escaping (AnyHashable) -> EffectPublisher = { _ in - _unimplemented("stopUpdatingLocation") - } - ) -> Self { - fatalError() - } - } - - public func _unimplemented( - _ function: StaticString, file: StaticString = #file, line: UInt = #line - ) -> Never { - fatalError( - """ - `\(function)` was called but is not implemented. Be sure to provide an implementation for - this endpoint when creating the mock. - """, - file: file, - line: line - ) - } -#endif diff --git a/Sources/ComposableCoreLocation/Internal/Exports.swift b/Sources/ComposableCoreLocation/Internal/Exports.swift index 09dced9..b1c5e3b 100644 --- a/Sources/ComposableCoreLocation/Internal/Exports.swift +++ b/Sources/ComposableCoreLocation/Internal/Exports.swift @@ -1,2 +1,2 @@ -@_exported import ComposableArchitecture +@_exported import Combine @_exported import CoreLocation diff --git a/Sources/ComposableCoreLocation/Internal/Publisher+Extensions.swift b/Sources/ComposableCoreLocation/Internal/Publisher+Extensions.swift new file mode 100644 index 0000000..6b8b742 --- /dev/null +++ b/Sources/ComposableCoreLocation/Internal/Publisher+Extensions.swift @@ -0,0 +1,18 @@ +import Combine +import XCTestDynamicOverlay + +extension AnyPublisher { + static func unimplemented(_ prefix: String, file: StaticString = #file, line: UInt = #line) -> Self { + .fireAndForget { + XCTFail("\(prefix.isEmpty ? "" : "\(prefix) - ")An unimplemented publisher ran.", file: file, line: line) + } + } + + static func fireAndForget(_ work: @escaping () throws -> Void) -> Self { + Deferred { + try? work() + return Empty() + } + .eraseToAnyPublisher() + } +} diff --git a/Sources/ComposableCoreLocation/Live.swift b/Sources/ComposableCoreLocation/Live.swift index 92600e9..12388a3 100644 --- a/Sources/ComposableCoreLocation/Live.swift +++ b/Sources/ComposableCoreLocation/Live.swift @@ -1,5 +1,4 @@ import Combine -import ComposableArchitecture import CoreLocation extension LocationManager { @@ -19,16 +18,8 @@ extension LocationManager { public static var live: Self { let manager = CLLocationManager() - let delegate = EffectPublisher.run { subscriber in - let delegate = LocationManagerDelegate(subscriber) - manager.delegate = delegate - - return AnyCancellable { - _ = delegate - } - } - .share() - .eraseToEffect() + let delegate = LocationManagerDelegate() + manager.delegate = delegate return Self( accuracyAuthorization: { @@ -47,7 +38,9 @@ extension LocationManager { #endif return CLLocationManager.authorizationStatus() }, - delegate: { delegate }, + delegate: { + delegate.subject.eraseToAnyPublisher() + }, dismissHeadingCalibrationDisplay: { .fireAndForget { #if os(iOS) || os(macOS) || os(watchOS) || targetEnvironment(macCatalyst) @@ -110,22 +103,23 @@ extension LocationManager { } }, requestTemporaryFullAccuracyAuthorization: { purposeKey in - .run { subscriber in - #if (compiler(>=5.3) && !(os(macOS) || targetEnvironment(macCatalyst))) || compiler(>=5.3.1) - if #available(iOS 14.0, tvOS 14.0, watchOS 7.0, macOS 11.0, macCatalyst 14.0, *) { - manager.requestTemporaryFullAccuracyAuthorization( - withPurposeKey: purposeKey - ) { error in - subscriber.send(completion: error.map { .failure(.init($0)) } ?? .finished) - } - } else { - subscriber.send(completion: .finished) - } - #else - subscriber.send(completion: .finished) - #endif - return AnyCancellable {} + let subject = PassthroughSubject() + + #if (compiler(>=5.3) && !(os(macOS) || targetEnvironment(macCatalyst))) || compiler(>=5.3.1) + if #available(iOS 14.0, tvOS 14.0, watchOS 7.0, macOS 11.0,macCatalyst 14.0, *) { + manager.requestTemporaryFullAccuracyAuthorization( + withPurposeKey: purposeKey + ) { error in + subject.send(completion: error.map { .failure(.init($0)) } ?? .finished) + } + } else { + subject.send(completion: .finished) } + #else + subject.send(completion: .finished) + #endif + + return subject.eraseToAnyPublisher() }, set: { properties in .fireAndForget { @@ -247,24 +241,20 @@ extension LocationManager { } private class LocationManagerDelegate: NSObject, CLLocationManagerDelegate { - let subscriber: EffectPublisher.Subscriber - - init(_ subscriber: EffectPublisher.Subscriber) { - self.subscriber = subscriber - } + let subject = PassthroughSubject() func locationManager( _ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus ) { - self.subscriber.send(.didChangeAuthorization(status)) + self.subject.send(.didChangeAuthorization(status)) } func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) { - self.subscriber.send(.didFailWithError(LocationManager.Error(error))) + self.subject.send(.didFailWithError(LocationManager.Error(error))) } func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { - self.subscriber.send(.didUpdateLocations(locations.map(Location.init(rawValue:)))) + self.subject.send(.didUpdateLocations(locations.map(Location.init(rawValue:)))) } #if os(macOS) @@ -272,7 +262,7 @@ private class LocationManagerDelegate: NSObject, CLLocationManagerDelegate { _ manager: CLLocationManager, didUpdateTo newLocation: CLLocation, from oldLocation: CLLocation ) { - self.subscriber.send( + self.subject.send( .didUpdateTo( newLocation: Location(rawValue: newLocation), oldLocation: Location(rawValue: oldLocation) @@ -285,7 +275,7 @@ private class LocationManagerDelegate: NSObject, CLLocationManagerDelegate { func locationManager( _ manager: CLLocationManager, didFinishDeferredUpdatesWithError error: Error? ) { - self.subscriber.send( + self.subject.send( .didFinishDeferredUpdatesWithError(error.map(LocationManager.Error.init)) ) } @@ -293,31 +283,31 @@ private class LocationManagerDelegate: NSObject, CLLocationManagerDelegate { #if os(iOS) || targetEnvironment(macCatalyst) func locationManagerDidPauseLocationUpdates(_ manager: CLLocationManager) { - self.subscriber.send(.didPauseLocationUpdates) + self.subject.send(.didPauseLocationUpdates) } #endif #if os(iOS) || targetEnvironment(macCatalyst) func locationManagerDidResumeLocationUpdates(_ manager: CLLocationManager) { - self.subscriber.send(.didResumeLocationUpdates) + self.subject.send(.didResumeLocationUpdates) } #endif #if os(iOS) || os(watchOS) || targetEnvironment(macCatalyst) func locationManager(_ manager: CLLocationManager, didUpdateHeading newHeading: CLHeading) { - self.subscriber.send(.didUpdateHeading(newHeading: Heading(rawValue: newHeading))) + self.subject.send(.didUpdateHeading(newHeading: Heading(rawValue: newHeading))) } #endif #if os(iOS) || os(macOS) || targetEnvironment(macCatalyst) func locationManager(_ manager: CLLocationManager, didEnterRegion region: CLRegion) { - self.subscriber.send(.didEnterRegion(Region(rawValue: region))) + self.subject.send(.didEnterRegion(Region(rawValue: region))) } #endif #if os(iOS) || os(macOS) || targetEnvironment(macCatalyst) func locationManager(_ manager: CLLocationManager, didExitRegion region: CLRegion) { - self.subscriber.send(.didExitRegion(Region(rawValue: region))) + self.subject.send(.didExitRegion(Region(rawValue: region))) } #endif @@ -325,7 +315,7 @@ private class LocationManagerDelegate: NSObject, CLLocationManagerDelegate { func locationManager( _ manager: CLLocationManager, didDetermineState state: CLRegionState, for region: CLRegion ) { - self.subscriber.send(.didDetermineState(state, region: Region(rawValue: region))) + self.subject.send(.didDetermineState(state, region: Region(rawValue: region))) } #endif @@ -333,7 +323,7 @@ private class LocationManagerDelegate: NSObject, CLLocationManagerDelegate { func locationManager( _ manager: CLLocationManager, monitoringDidFailFor region: CLRegion?, withError error: Error ) { - self.subscriber.send( + self.subject.send( .monitoringDidFail( region: region.map(Region.init(rawValue:)), error: LocationManager.Error(error))) } @@ -341,7 +331,7 @@ private class LocationManagerDelegate: NSObject, CLLocationManagerDelegate { #if os(iOS) || os(macOS) || targetEnvironment(macCatalyst) func locationManager(_ manager: CLLocationManager, didStartMonitoringFor region: CLRegion) { - self.subscriber.send(.didStartMonitoring(region: Region(rawValue: region))) + self.subject.send(.didStartMonitoring(region: Region(rawValue: region))) } #endif @@ -350,7 +340,7 @@ private class LocationManagerDelegate: NSObject, CLLocationManagerDelegate { _ manager: CLLocationManager, didRange beacons: [CLBeacon], satisfying beaconConstraint: CLBeaconIdentityConstraint ) { - self.subscriber.send( + self.subject.send( .didRangeBeacons( beacons.map(Beacon.init(rawValue:)), satisfyingConstraint: beaconConstraint ) @@ -363,7 +353,7 @@ private class LocationManagerDelegate: NSObject, CLLocationManagerDelegate { _ manager: CLLocationManager, didFailRangingFor beaconConstraint: CLBeaconIdentityConstraint, error: Error ) { - self.subscriber.send( + self.subject.send( .didFailRanging(beaconConstraint: beaconConstraint, error: LocationManager.Error(error)) ) } @@ -371,7 +361,7 @@ private class LocationManagerDelegate: NSObject, CLLocationManagerDelegate { #if os(iOS) || targetEnvironment(macCatalyst) func locationManager(_ manager: CLLocationManager, didVisit visit: CLVisit) { - self.subscriber.send(.didVisit(Visit(visit: visit))) + self.subject.send(.didVisit(Visit(visit: visit))) } #endif }