以下功能假定要获取阻止用户的列表,然后获取被用户阻止合并两个列表,并将其作为{{1} }。
以下是向控制台输出的内容,它告诉我[String]
return
的调用很早-在将数组传回之前,我如何强制两个watchSingleEvents函数完成调用方方法?
1 4 2 3
blockedList
功能func getBlockedUsersList() -> [String]{
var blockedList = [String]()
var blockedUsers = [String]()
var blockedByUsers = [String]()
print("1")
DataService.run.getBlockedByUsersList { (success, blockedByUsersList) in
print("2")
if success {
blockedByUsers = blockedByUsersList
DataService.run.getBlockedUsersList(handler: { (success, blockedUsersList) in
print("3")
if success {
blockedUsers = blockedUsersList
blockedList = Array(Set(blockedUsers + blockedByUsers))
}//end if-success
})//getBlockedUsersList
}//end if-success
}//end getBlockedByUsersList
print("4")
return blockedList
}//end func
从Firebase获取列表:
getBlockedByUsersList