Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
291 views
in Technique[技术] by (71.8m points)

android - What actually happens when persistence is enabled in Firebase?

When turning on persistence for Firebase in iOS what actually happens to my observers and how they behave on a technical level?

I have a good idea how it should work on a high-level based on this https://firebase.google.com/docs/database/ios/offline-capabilities - Firebase essentially keeps a cached copy of the data you can access whilst offline.

What I don't understand is how many times my observers should fire and with what information.

  • Does firebase always trigger my observers once with any cached data first (or null if there isn't any data) followed by the server data.
  • Or does it only send the cached data if it exists followed by the server data.
  • Is there any difference between observerSingleValue and a continous observer's behaviour when in persistence mode ?

In our app with persistence enabled, I have noticed:

  • Firebase just sending the server data
  • Firebase sending the cached data if it exists then the server data.
  • Firebase sending the cached data and null if it doesn't exist followed by the server data.

It would be good to clear this up so we know which should be the normal behaviour :)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...