@@ -10,15 +10,18 @@ import CoreLocation
1010///Location manager streaming data asynchronously via instance of ``AsyncStream`` returning from ``start``
1111@available ( iOS 15 . 0 , * )
1212public final class LocationManagerAsync : NSObject , ILocationManagerAsync {
13-
13+
14+ private typealias StreamType = AsyncStream < CLLocation > . Continuation
15+
16+ // MARK: - Private properties
17+
18+ /// Async stream of locations
1419 private var locations : AsyncStream < CLLocation > {
1520 . init( CLLocation . self) { continuation in
1621 streaming ( with: continuation)
1722 }
1823 }
19-
20- private typealias StreamType = AsyncStream < CLLocation > . Continuation
21-
24+
2225 /// Continuation asynchronously passing location data
2326 private var stream : StreamType ? {
2427 didSet {
@@ -42,6 +45,9 @@ public final class LocationManagerAsync: NSObject, ILocationManagerAsync{
4245
4346 // MARK: - Life circle
4447
48+ /// - Parameters:
49+ /// - accuracy: The accuracy of a geographical coordinate.
50+ /// - backgroundUpdates: A Boolean value that indicates whether the app receives location updates when running in the background
4551 public convenience init ( _ accuracy : CLLocationAccuracy ? ,
4652 _ backgroundUpdates : Bool = false ) {
4753
@@ -65,7 +71,7 @@ public final class LocationManagerAsync: NSObject, ILocationManagerAsync{
6571 /// Check status and get stream of async data
6672 public var start : AsyncStream < CLLocation > {
6773 get async throws {
68- if await getStatus {
74+ if await getPermission {
6975 return locations
7076 }
7177 throw LocationManagerErrors. accessIsNotAuthorized
@@ -80,8 +86,8 @@ public final class LocationManagerAsync: NSObject, ILocationManagerAsync{
8086
8187 // MARK: - Private
8288
83- /// Get status
84- private var getStatus : Bool {
89+ /// Get status asynchronously and check is it authorized to start getting the stream of locations
90+ private var getPermission : Bool {
8591 get async {
8692 let status = await requestPermission ( )
8793 return isAuthorized ( status)
@@ -124,7 +130,7 @@ public final class LocationManagerAsync: NSObject, ILocationManagerAsync{
124130 stream? . yield ( location)
125131 }
126132
127- /// check permission status
133+ /// Check permission status
128134 /// - Parameter status: Status for checking
129135 /// - Returns: Return `True` if is allowed
130136 private func isAuthorized( _ status : CLAuthorizationStatus ) -> Bool {
0 commit comments