Skip to content

Commit 789bab4

Browse files
committed
update
1 parent 6ecae14 commit 789bab4

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
### 3. Call ViewModel method start() within async environment
2323
If task will be canceled the streaming stops automatically
24-
I would recomend to use .task modifire it manages cancelation if you desided to use Task and keep it in @State don't forget to cancel() when the time has come
24+
I would recomend to use .task modifire it manages cancelation if you desided to use Task and keep it in @State don't forget to cancel() when the time has come or it might course memory leaks in some cases
2525
```
2626
.task{
2727
do{

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public final class LMViewModel: ILocationManagerViewModel{
6565
}
6666
}catch{
6767

68-
state = .idle
68+
state = .idle // if access was not granted just set state as idle, manager did not get start in this case
6969

7070
if isStreamCancelled(with: error){ stop() }
7171

@@ -86,6 +86,10 @@ public final class LMViewModel: ILocationManagerViewModel{
8686

8787
// MARK: - Private
8888

89+
90+
/// Check if it is cancelation error
91+
/// - Parameter error: Error from manager
92+
/// - Returns: true is stream was canceled
8993
func isStreamCancelled(with error : Error) -> Bool{
9094

9195
if let e = error as? AsyncLocationErrors{
@@ -94,7 +98,9 @@ public final class LMViewModel: ILocationManagerViewModel{
9498

9599
return false
96100
}
97-
101+
102+
/// Add new location
103+
/// - Parameter coordinate: data
98104
@MainActor
99105
private func add(_ coordinate : CLLocation) {
100106
locations.append(coordinate)

0 commit comments

Comments
 (0)