--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/d5581e0e-338f-4981-9d56-395d4df624f4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
mFirebase.child("messages").child("receivers").addListenerForSingleValueEvent(new ValueEventListener() {
@Override public void onDataChange(DataSnapshot dataSnapshot) {
// Does dataSnapshot contains all modifications until now, without /messages/receivers being “kept sync”?
}
@Override public void onCancelled(FirebaseError firebaseError) {}
});I know the dataSnapshot would be up to date if the listener had been added using addValueEventListener() instead.Thanks for your time.F.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/CADypTEZyY7eqQ8gPsYOCeu73vBs4CLEO9xYXoeP-1VLuMw4%2BCQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/E48BAFEE-621A-4D24-92DB-5BEEBD751851%40gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/CADypTEbub3ChHjFYHkiPrK1jZ9z%2B%2B_19_Z5s2LfbBBEe9cxqfQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/FE090E22-3613-4314-9D51-A361928009D5%40gmail.com.
mFirebase.child("path").child("val").addValueEventListener(new ValueEventListener() {
@Override public void onDataChange(DataSnapshot dataSnapshot) {
int val = dataSnapshot.getValue(Integer.class); // Is val 1 or 2 here?
}
@Override public void onCancelled(FirebaseError firebaseError) {
}
});To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/CADypTEYGN63qmRtLNSZwu2HdnWvaC0RmhPEKectB_yDBJ6J4OA%40mail.gmail.com.
// Is val 1 or 2 here?
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/111DEE4B-E9CB-49C9-AB60-3BA44BC43826%40gmail.com.
On 04 Sep 2015, at 18:29, Kato Richardson <wu...@firebase.com> wrote:
// Is val 1 or 2 here?This depends on when this is called relative to the other operations and when and how you're calling keepSynced(). Could you please include the relevant code that's setting the value and calling keepSynced()?
On Thu, Sep 3, 2015 at 1:15 PM, François Perret <app.b...@gmail.com> wrote:
Hi Kato,Here is a simple use case (question is in the commented code below).
- User 1 creates /path/{val:1}
- User 2 sets /path/val to 2
- User 1 reads /path/val (no keepSync on /path/ nor /path/val/ here)
mFirebase.child("path").child("val”).addListenerForSingleValueEvent(new ValueEventListener() {
F.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/CADypTEbn6XAtu%2BEJppWZTVNuxRX8aMpzxrnhL008HisEn6M%2BbA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/9EB18B78-68AA-4D24-BC7C-25FE836FCFD8%40gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/CADypTEb63GD3_L%3Dd%3DoDX2gYYvkte88QPZVjXpdVm-irFWgh%3D4w%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/CAJCyStfyzWtd%3DyZ5LAy191o2A9G8Rwov5zi6L2ydhhDewKDd0A%40mail.gmail.com.
You received this message because you are subscribed to a topic in the Google Groups "Firebase Google Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/firebase-talk/ptTtEyBDKls/unsubscribe.
To unsubscribe from this group and all its topics, send an email to firebase-tal...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/1aa5dc49-4b91-4fe5-b15a-b1863632231a%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/4c5d2df7-b8a1-4652-9626-45e2e7765b3c%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/8AE62D07-A164-45C7-8D16-DF9AA65954BC%40gmail.com.
Hey François,The behavior for addListenerForSingleValueEvent is:
- If we have cached data: raise an event with whatever we have cached (this may be stale).
- Send a request to the server to get the latest data.
This means that you may get stale data in your event callback. You should get fresher data the next time you call addListenerForSingleValueEvent (since we'll have tried to update the cache).We know this isn't ideal behavior and are looking into ways to improve it. For now, using keepSynced() is a good approach to make sure it's as fresh as possible.
Thank you all. Makes perfect sense.Sent from my iPhone 6
Hi Evans,
There is no built-in way to be aware of the sync completion of you local cached version of a given path data and the server one.
Here are your best choices:
- A single value listener (actually a value listener, added with addListenerForSingleValueEvent) and a keepSync on the path, which will be triggered once.
- A normal event listener (value or child flavour, added with addValueEventListener or addChildEventListener, resp.) which might be triggered several time.
Under the hood it might be the same thing, since it is my guess that keepSync(true) implementation shouldn’t be far from just adding a listener.Hope this helps.F.
To unsubscribe from this group and stop receiving emails from it, send an email to fireba...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/4c5d2df7-b8a1-4652-9626-45e2e7765b3c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "Firebase Google Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/firebase-talk/ptTtEyBDKls/unsubscribe.
To unsubscribe from this group and all its topics, send an email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/ece286f2-727a-4720-ab2f-c2f34c4e0f50%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/CADypTEZbep0ax7_VO%3DZ640VbgtC%3D5kXW8XHTtDLXF13gK6-7Pw%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/CAK2nJo3Twcurb-GipFfSxe8ecJ6mv806r%2B%3Dx%2Bq06zZ_An%3DuqUQ%40mail.gmail.com.