Skip to content

Commit 10ee076

Browse files
committed
update
1 parent 241fc5a commit 10ee076

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@
4747
case accessIsNotAuthorized
4848
4949
/// Attempt to launch streaming again while it's been already started
50-
case streamHasAlreadyStarted
50+
/// Subscribe different Views to LMViewModel.locations publisher to feed them
51+
case streamingProcessHasAlreadyStarted
5152
```
5253

5354
## ViewModel API

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ public enum LocationManagerErrors: Error{
1515
case accessIsNotAuthorized
1616

1717
/// Attempt to launch streaming while it's been already started
18-
case streamHasAlreadyStarted
18+
/// Subscribe different Views to LMViewModel.locations publisher to feed them
19+
case streamingProcessHasAlreadyStarted
1920
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Foundation
1111
@available(iOS 15.0, watchOS 7.0, *)
1212
enum LocationStreamingState{
1313

14-
case idle
15-
14+
case idle
15+
1616
case streaming
1717
}

Sources/d3-async-location/viewmodel/LMViewModel.swift

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,22 @@ public actor LMViewModel: ILocationManagerViewModel{
5252

5353
/// Start streaming locations
5454
public func start() async throws{
55-
if isIdle{
56-
state = .streaming
55+
56+
guard isIdle else{
57+
throw LocationManagerErrors.streamingProcessHasAlreadyStarted
58+
}
59+
60+
state = .streaming
61+
62+
do {
5763
for await coordinate in try await manager.start{
5864
await add(coordinate)
5965
}
60-
}else{
61-
throw LocationManagerErrors.streamHasAlreadyStarted
66+
}catch{
67+
state = .idle
68+
throw error
6269
}
70+
6371
}
6472

6573
/// Start streaming locations

0 commit comments

Comments
 (0)