1

The docs for the current Firebase Admin SDK as well as the 2.5.1 Firebase iOS SDK (now legacy) mentions some guarantees regarding events, the most relevant one to me being:

Value events are always triggered last and are guaranteed to contain updates from any other events which occurred before that snapshot was taken.

Does this still stand with respect to the iOS SDK (the current docs for which have since removed the table containing the guarantees), especially when interlacing observe and observeSingleEvent calls? In other words, if I were to call this code on app startup:

ref.child("users").observe(.childAdded) { snapshot in
    print("Child added")
}
ref.child("users").observeSingleEvent(of: .value) { snapshot in
    print("Value event")
}

Will I get a guarantee that the childAdded events are fired before the value event? In other words, will I get something this in the console, assuming there are 3 children under users?

Child added
Child added
Child added
Value event

More context:

I'm trying to load an initial blob of data from Firebase, after which I want to inform the application that it has received all initial data. In other words, I want to do something like this answer has suggested. Some simple experiments affirm that the guarantee is maintained, but this answer also suggests that interlacing observe and observeSingleEvent calls when local data is available will break the guarantee.

ReyAnthonyRenacia
  • 17,219
  • 5
  • 37
  • 56
peco
  • 1,411
  • 3
  • 17
  • 38
  • "Does this still stand with respect to the iOS SDK" Yes, nothing has changed for this in years, nor is it likely to change in the future. If you're having problems, please share the minimal code that reproduces the problems. – Frank van Puffelen Jan 30 '18 at 05:09
  • No problems faced, but I do want a proper guarantee before the code is deployed - especially seeing that the list of guarantees is no longer present in the iOS docs. – peco Jan 30 '18 at 06:31

0 Answers0