How to separate initial data load from incremental children with Firebase?

后端 未结 4 1555
[愿得一人]
[愿得一人] 2020-11-30 03:09

I have an application where new children get added to Firebase every 5 seconds or so. I have thousands of children.

On application load, I\'d like to process the ini

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-30 03:52

    There are two possible solutions to this problem, neither satisfying:

    1) Timestamp your children and only request children that have a timestamp greater than a "now" value. This is not great because you may have a synchronicity issue between your application's "now" and the "now" on whatever is pushing the data to Firebase or the Firebase server value for "now".

    2) Use value and child added. Any duplicates seen in child_added that had already been seen in value may be discarded. This is unuseable for large data sets as it requires downloading all historical data TWICE!

    Why can't there be a command like "child_added" that DOESN'T give everything ever?

提交回复
热议问题