Let's say that I have it
FIRDatabase.database.reference.child("somechild").observeSingleEventOfType(.Value, withBlock{(snapshot) in
Please do not read too much in the code snippet, asking for more code, I only need a short answer. Where he says “a bunch of code,” suppose it is actually code that is in the MAIN queue. Now, when I write the checkSingleEvent Firebase completion handler, my analysis on it is as follows.
observSingleEvent retrieves the snapshot in the background so as not to block the user interface that is in the main queue.
After it takes a snapshot, the block of code after "in" is now returned to the MAIN queue, so you can put any code associated with the UI there.
My entire application is based on this reasoning, so if I am mistaken, tell me what really happens.
source
share