override func viewDidLoad() {
// function calling
querySomething { (completed) in
print("completed :", completed)
}
}
func querySomething(completion: @escaping (Bool) -> Void) {
let db = Firestore.firestore()
db.collection("collectionName").document().addSnapshotListener { (documentSnapshot, error) in
if error != nil {
completion(false)
return
}
completion(true)
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter