I attempt to run the next code part. But it does not await completion of .checkConnectionQuality
and sends two calls in a row. Is there a way to run this code in a queue one by one?
I've tried . concatenate
but looks like it has the same effect.
case .synchronize:
return .run {
send in
await send(.checkConnectionQuality)
await send(.checkConnectionQuality)
}
case .checkConnectionQuality:
state.qualityTest = .undefined
guard reachability.isAvailable else {
return .send(
.connectionQuality(quality: .notConnected))
}
return .run { send in
do {
let result = try await networkQuality.networkConnectionTest()
switch result {
case .success(let speed):
await send(
.connectionQuality(quality:
.measure(speed: speed)))
break
case .failure(_):
await send(
.connectionQuality(quality: .notConnected))
break
}
} catch {
await send(
.connectionQuality(quality: .notConnected))
}
}