Firebase keepSynced(true)

后端 未结 1 914
南笙
南笙 2021-02-13 17:01

What are the trade-offs when I use sync on several paths in my Firebase database?

databaseRef.keepSynced(true);

I never clear the sync from th

相关标签:
1条回答
  • 2021-02-13 17:12

    When you use the keepSynced() method, you're telling Firebase to download and cache all the data from databaseRef. I hope databaseRef isn't the root Reference of your Database because if it is, you're downloading your entire database and this is not a good practice.

    You should use keepSynced() to cache nodes that are really necessary for your app to work offline.

    You will probably be wondering how is it different from setPersistanceEnabled(true). Well, setPersistanceEnabled(true) only caches data when there is a Listener attached to that node (when the data has been read at least once).

    On the other hand, keepSynced(true) caches everything from that node, even if there is no listener attached.

    0 讨论(0)
提交回复
热议问题