0

I need to know if the events i am getting from the observeEventType method are before or after the connection was establish, without having to add an timestamp on every message.

Should be possible to get only fresh messages because it is simple to implement, but can't find a way to do it using just the firebase interface.

MiguelSlv
  • 14,067
  • 15
  • 102
  • 169
  • Firebase synchronizes all state, not just changes. You can either [throw away the initial state](http://stackoverflow.com/questions/18270995/how-to-retreive-only-new-data) or [query to get only new data (by timestamp)](http://stackoverflow.com/questions/19883736/how-to-discard-initial-data-in-a-firebase-db/27693310#27693310). – Frank van Puffelen Jul 08 '16 at 17:52
  • i don't see how i can throw away the initial state. When i call observeEventType, the message passed to the block as no indication if was there before or after i connect. Unless i tag then with a timestamp i don't see how. – MiguelSlv Jul 08 '16 at 19:24
  • The first answer I linked contains an example of using the combination of `value` and `child_added` events to discard the initial data. – Frank van Puffelen Jul 08 '16 at 22:13
  • Was so convicted that there was no solution that i misread your comment. I look deep into the answer. The solution present appears to be just a patch, the data is downloaded anyway. As Gruff McGruff posts, `once` looks just a race condition. – MiguelSlv Jul 09 '16 at 13:49
  • The solutions presented in the two questions I linked are used by many developers building apps on the Firebase Database to distinguish new data from existing data. I'll gladly add your vote for changing the API, many of our changes have come out of such developer feedback. But there's not a lot more we can do here on Stack Overflow. – Frank van Puffelen Jul 09 '16 at 15:41
  • At this point i am not 100% sure i will need it, my app features are still being refined. Solution 2 works for me in case, so my vote shouldn't count for now. Thanks for your assistance. – MiguelSlv Jul 09 '16 at 17:06

0 Answers0