Lets say I have this
// a bunch of code...
FIRDatabase.database.reference.child("somechild").observeSingleEventOfType(.Value, withBlock{(snapshot) in
//some code inside of the completion handler})
Please don't read too much into the code snippet asking for more code, I only require a short answer. Where it says, "a bunch of code", assume that its actually some code that's on the MAIN queue. Now, when I write down the observeSingleEvent Firebase completion handler, my analysis on it is this.
observeSingleEvent fetches the snapshot on a background queue as to not block UI thats on the main queue.
Once it fetches the snapshot, the block of code after "in" is now back to the MAIN queue, so its fine to put any UI related code in there.
My whole app is based on this reasoning, so if I'm incorrect, please tell me what's actually going on.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…