Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
[ad_1]
I’ve the next code, I want to use async-await for the 2 calls.
In the intervening time contained in the perform I used a type of verify variable, which when each are set the code is executed.
How can I do?
....
.onAppear {
DispatchQueue.world(qos: .background).async {
getRemoteHead(url: repoUrlStr)
getRemoteBranch(url: repoUrlStr)
}
}
func getRemoteHead(url: String) {
do {
let department = strive Distant().getRemoteHEAD(url: url)
if department[0].comprises("deadly:") {
Log.warning("Error: getRemoteHead")
activeSheet = .error("Error: getRemoteHead")
} else {
self.mainBranch = department[0]
self.selectedBranch = department[0]
self.verify += 1
if verify == 2 {
verify = 0
activeSheet = .choose
}
}
} catch {
Log.error("Failed to seek out predominant department title.")
}
}
func getRemoteBranch(url: String) {
do {
let branches = strive Distant().getRemoteBranch(url: url)
if branches[0].comprises("deadly:") {
Log.warning("Error: getRemoteBranch")
activeSheet = .error("Error: getRemoteBranch")
} else {
self.arrayBranch = branches
self.verify += 1
if verify == 2 {
verify = 0
activeSheet = .choose
DispatchQueue.predominant.asyncAfter(deadline: .now() + 0.1) {
// Drive a UI Replace.
allBranches.toggle()
}
}
}
} catch {
Log.error("Failed to seek out branches.")
}
}
[ad_2]