Skip to content

Commit

Permalink
feat: add docs for CLLocation authorization
Browse files Browse the repository at this point in the history
  • Loading branch information
gtokman committed May 6, 2021
1 parent 7e2df3a commit 6672ed8
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions Sources/ExtensionKit/CoreLocation/CLLocationManager.swift
Expand Up @@ -3,6 +3,41 @@ import CoreLocation

public extension CLLocationManager {

/*
```
class LocationStore: ObservableObject {
@Published var coordinate: CLLocationCoordinate2D = .zero
@Published var status: CLAuthorizationStatus = .notDetermined
let manager = CLLocationManager()
var cancellables = Set<AnyCancellable>()
func requestPermission() {
CLLocationManager
.requestLocationAuthorization(with: manager, type: .whenInUse)
.assign(to: \.status, on: self)
.store(in: &cancellables)
}
func getLocation() {
CLLocationManager
.receiveLocationUpdates(from: manager)
.compactMap(\.last)
.map(\.coordinate)
.sink { result in
if case let .failure(error) = result {
dprint("Error: \(error.localizedDescription)")
}
} receiveValue: { coordinate in
self.coordinate = coordinate
}
.store(in: &cancellables)
}
}
```
**/
/// Request locaton authorization and subscribe to `CLAuthorizationStatus` updates
/// - Parameters:
/// - manager: `CLLocationManager`
Expand Down

0 comments on commit 6672ed8

Please sign in to comment.