File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed
Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change 11# AsyncLocationKit
2+
3+ Wrapper for Apple ` CoreLocation ` framework with new Concurency Model. No more ` delegate ` patter or ` completion blocks ` .
4+
5+ ``` swift
6+ import AsyncLocationKit
7+
8+ let asyncLocationManager = AsyncLocationManager (desiredAccuracy : .bestAccuracy )
9+
10+ Task {
11+ let permission = await self .asyncLocationManager .requestAuthorizationWhenInUse () // returns CLAuthorizationStatus
12+ }
13+ ```
14+
15+ You can use all methods from Apple ` CLLocationManager ` .
16+
17+ ``` swift
18+ Task {
19+ let coordinate = try await asyncLocationManager.requestLocation () // Request user location once
20+ }
21+ ```
22+
23+ Start monitoring update of user location with ` AsyncStream ` .
24+
25+ ``` swift
26+ Task {
27+ for await locationUpdateEvent in await asyncLocationManager.startUpdatingLocation () {
28+ switch locationUpdateEvent {
29+ case .didUpdateLocations (let locations):
30+ // do something
31+ case .didFailWith (let error):
32+ // do something
33+ case .didPaused , .didResume :
34+ break
35+ }
36+ }
37+ }
38+ ```
39+
40+ If ` Task ` was canceled, Stream finished automaticaly.
You can’t perform that action at this time.
0 commit comments