I have two async streams. The first is PathMonitorClient
that simply streams NWPath.Status
.
The second is a databaseClient
that publishes my database changes.
I want to only upload my database changes when NWPath.Status == .satisfied.
Here is my current code
var lastValue: NWPath.Status?
for await path in pathMonitorClient.networkPath() {
lastValue = path.status
for await tables in await databaseClient.tables() {
if lastValue == .satisfied {
// upload
}
}
}
But, when the status changes to .unsatisfied
, lastValue
is never set, and my // upload
code continues to be called.