-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use TaskGroup to wait on network activating or retry timeout, whichev…
…er is first (#102) * Add NWPathMonitor logic to WebSocketProvider retries * Add NWPathMonitor logic to WebSocketProvider retries (using group) * Remove inadvertent comment changes * Return proper success * Cleanup comments
- Loading branch information
1 parent
39f75a8
commit c24502c
Showing
2 changed files
with
57 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
Sources/AutomergeRepo/extensions/NWPathMonitor+paths.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import Network | ||
|
||
extension NWPathMonitor { | ||
func paths() -> AsyncStream<NWPath> { | ||
AsyncStream { continuation in | ||
pathUpdateHandler = { path in | ||
continuation.yield(path) | ||
} | ||
continuation.onTermination = { [weak self] _ in | ||
self?.cancel() | ||
} | ||
start(queue: DispatchQueue(label: "NSPathMonitor.paths")) | ||
} | ||
} | ||
} |