File tree 4 files changed +24
-5
lines changed
Sources/d3-async-location
4 files changed +24
-5
lines changed Original file line number Diff line number Diff line change @@ -51,9 +51,12 @@ If task will be canceled the streaming stops automatically. I would recommend to
51
51
/// Subscribe different Views to LMViewModel.locations publisher to feed them
52
52
case streamingProcessHasAlreadyStarted
53
53
54
- /// Stream was cancelled or terminated
55
- case streamTerminated
54
+ /// Stream was cancelled
55
+ case streamCanceled
56
56
57
+ /// Stream was terminated
58
+ case streamUnknownTermination
59
+
57
60
/// A Core Location error
58
61
case coreLocationManagerError(CLError)
59
62
```
Original file line number Diff line number Diff line change @@ -25,6 +25,12 @@ extension LocationManagerAsync{
25
25
26
26
// MARK: - Delegate
27
27
28
+
29
+ /// Stop streaming
30
+ public func finish( ) {
31
+ stream? . finish ( )
32
+ }
33
+
28
34
/// Pass `CLLocation` into the async stream
29
35
/// - Parameters:
30
36
/// - manager: Location manager
@@ -61,7 +67,14 @@ extension LocationManagerAsync{
61
67
/// - Parameter termination: A type that indicates how the stream terminated.
62
68
private func onTermination( _ termination: Termination ) {
63
69
let type = AsyncLocationErrors . self
64
- stream? . finish ( throwing: type. streamTerminated)
70
+ switch ( termination) {
71
+ case . finished( _) : fallthrough
72
+ case . cancelled: stream? . finish ( throwing: type. streamCanceled)
73
+ @unknown default :
74
+ stream? . finish ( throwing: type. streamUnknownTermination)
75
+ }
76
+
77
+ stream = nil
65
78
}
66
79
67
80
/// Passing ``CLLocation`` data
Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ final class LocationManagerAsync: ILocationManagerAsync{
64
64
65
65
/// Stop streaming
66
66
public func stop( ) {
67
- delegate. stream = nil
67
+ delegate. finish ( )
68
68
manager. stopUpdatingLocation ( )
69
69
70
70
#if DEBUG
Original file line number Diff line number Diff line change @@ -19,8 +19,11 @@ public enum AsyncLocationErrors: Error{
19
19
case streamingProcessHasAlreadyStarted
20
20
21
21
/// Stream was cancelled or terminated
22
- case streamTerminated
22
+ case streamCanceled
23
23
24
+ /// Stream was cancelled or terminated
25
+ case streamUnknownTermination
26
+
24
27
/// A Core Location error
25
28
case coreLocationManagerError( CLError )
26
29
You can’t perform that action at this time.
0 commit comments