44//
55// Created by Igor on 03.02.2023.
66//
7-
7+ import Foundation
88import CoreLocation
99
1010
11- /// Manager of locations streaming data asynchronously
11+ ///Location manager streaming data asynchronously via property ``locations``
1212@available ( iOS 15 . 0 , * )
1313public final class LocationManagerAsync : NSObject , CLLocationManagerDelegate {
1414
@@ -27,6 +27,7 @@ public final class LocationManagerAsync: NSObject, CLLocationManagerDelegate{
2727
2828 private typealias StreamType = AsyncStream < CLLocation > . Continuation
2929
30+ /// Continuation asynchronosly passing location data
3031 private var stream : StreamType ? {
3132 didSet {
3233 stream? . onTermination = { @Sendable _ in self . stop ( ) }
@@ -104,10 +105,14 @@ public final class LocationManagerAsync: NSObject, CLLocationManagerDelegate{
104105 manager. startUpdatingLocation ( )
105106 }
106107
107- private func yield( location : CLLocation ) {
108+
109+ /// Passing location data
110+ /// - Parameter location: Location data
111+ private func pass( location : CLLocation ) {
108112 stream? . yield ( location)
109113 }
110114
115+ /// Convenience func to check status
111116 private func checkStatus( ) throws {
112117 if !isDetermined{
113118 throw LocationManagerErrors . statusIsNotDetermined
@@ -121,7 +126,7 @@ public final class LocationManagerAsync: NSObject, CLLocationManagerDelegate{
121126 /// - manager: Location manager
122127 /// - locations: Array of locations
123128 public func locationManager( _ manager: CLLocationManager , didUpdateLocations locations: [ CLLocation ] ) {
124- locations. forEach { yield ( location: $0) }
129+ locations. forEach { pass ( location: $0) }
125130 }
126131
127132 /// Determine status after the request permission
0 commit comments