Skip to content

Commit bb3d132

Browse files
committed
update
1 parent 2dba534 commit bb3d132

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed

README.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,12 @@ If task will be canceled the streaming stops automatically. I would recommend to
5151
/// Subscribe different Views to LMViewModel.locations publisher to feed them
5252
case streamingProcessHasAlreadyStarted
5353
54-
/// Stream was cancelled or terminated
55-
case streamTerminated
54+
/// Stream was cancelled
55+
case streamCanceled
5656
57+
/// Stream was terminated
58+
case streamUnknownTermination
59+
5760
/// A Core Location error
5861
case coreLocationManagerError(CLError)
5962
```

Sources/d3-async-location/LocationManagerAsync+/Delegate.swift

+14-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ extension LocationManagerAsync{
2525

2626
// MARK: - Delegate
2727

28+
29+
/// Stop streaming
30+
public func finish(){
31+
stream?.finish()
32+
}
33+
2834
/// Pass `CLLocation` into the async stream
2935
/// - Parameters:
3036
/// - manager: Location manager
@@ -61,7 +67,14 @@ extension LocationManagerAsync{
6167
/// - Parameter termination: A type that indicates how the stream terminated.
6268
private func onTermination(_ termination: Termination){
6369
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
6578
}
6679

6780
/// Passing ``CLLocation`` data

Sources/d3-async-location/LocationManagerAsync.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ final class LocationManagerAsync: ILocationManagerAsync{
6464

6565
/// Stop streaming
6666
public func stop(){
67-
delegate.stream = nil
67+
delegate.finish()
6868
manager.stopUpdatingLocation()
6969

7070
#if DEBUG

Sources/d3-async-location/enum/AsyncLocationErrors.swift

+4-1
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@ public enum AsyncLocationErrors: Error{
1919
case streamingProcessHasAlreadyStarted
2020

2121
/// Stream was cancelled or terminated
22-
case streamTerminated
22+
case streamCanceled
2323

24+
/// Stream was cancelled or terminated
25+
case streamUnknownTermination
26+
2427
/// A Core Location error
2528
case coreLocationManagerError(CLError)
2629

0 commit comments

Comments
 (0)