[ad_1]
I’ve the next code, I want to use async-await for the 2 calls.
In the meanwhile contained in the operate I used a form of test 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].accommodates("deadly:") {
Log.warning("Error: getRemoteHead")
activeSheet = .error("Error: getRemoteHead")
} else {
self.mainBranch = department[0]
self.selectedBranch = department[0]
self.test += 1
if test == 2 {
test = 0
activeSheet = .choose
}
}
} catch {
Log.error("Failed to seek out primary department identify.")
}
}
func getRemoteBranch(url: String) {
do {
let branches = strive Distant().getRemoteBranch(url: url)
if branches[0].accommodates("deadly:") {
Log.warning("Error: getRemoteBranch")
activeSheet = .error("Error: getRemoteBranch")
} else {
self.arrayBranch = branches
self.test += 1
if test == 2 {
test = 0
activeSheet = .choose
DispatchQueue.primary.asyncAfter(deadline: .now() + 0.1) {
// Power a UI Replace.
allBranches.toggle()
}
}
}
} catch {
Log.error("Failed to seek out branches.")
}
}
[ad_2]
