Skip to content

Commit 36db2cb

Browse files
mackojmluisbrown
authored andcommitted
Make location getter work like Corelocation.location getter (#205)
* Make location getter work like Corelocation.location getter It is now optional * Applying mbrandonw review comment
1 parent a86bf48 commit 36db2cb

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Sources/ComposableCoreLocation/Interface.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ public struct LocationManager {
268268
@available(watchOS, unavailable)
269269
public var isRangingAvailable: () -> Bool = { _unimplemented("isRangingAvailable") }
270270

271-
var location: (AnyHashable) -> Location = { _ in _unimplemented("location") }
271+
var location: (AnyHashable) -> Location? = { _ in _unimplemented("location") }
272272

273273
public var locationServicesEnabled: () -> Bool = { _unimplemented("locationServicesEnabled") }
274274

@@ -389,7 +389,7 @@ public struct LocationManager {
389389
@available(tvOS, unavailable)
390390
public func heading(id: AnyHashable) -> Heading? { self.heading(id) }
391391

392-
public func location(id: AnyHashable) -> Location { self.location(id) }
392+
public func location(id: AnyHashable) -> Location? { self.location(id) }
393393

394394
@available(tvOS, unavailable)
395395
@available(watchOS, unavailable)

Sources/ComposableCoreLocation/Live.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ extension LocationManager {
128128

129129
manager.locationServicesEnabled = CLLocationManager.locationServicesEnabled
130130

131+
manager.location = { id in dependencies[id]?.manager.location.map(Location.init(rawValue:)) }
132+
131133
manager.requestLocation = { id in
132134
.fireAndForget { dependencies[id]?.manager.requestLocation() }
133135
}

0 commit comments

Comments
 (0)