Last active
December 31, 2016 23:12
-
-
Save ramden/3addea21cf925ecd3c8c380f78679ad9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ############################################################################## | |
// Scenario 1: | |
// ############################################################################## | |
FirebaseDatabase.getInstance().setPersistenceEnabled(true); | |
FirebaseDatabase.getInstance().goOffline(); // <--------NOTE THIS | |
DatabaseReference mDatabase = FirebaseDatabase.getInstance().getReference(); | |
mDatabase.child("users").child(App.get().getUid()).child("items").addValueEventListener(new ValueEventListener() { | |
@Override | |
public void onDataChange(DataSnapshot dataSnapshot) { | |
// THIS IS NOT FIRING | |
} | |
@Override | |
public void onCancelled(DatabaseError databaseError) { | |
... | |
} | |
}); | |
// ############################################################################## | |
// After Scenario 1 I change code to this and run: | |
// ############################################################################## | |
FirebaseDatabase.getInstance().setPersistenceEnabled(true); | |
FirebaseDatabase.getInstance().goOnline(); // <--------NOTE THIS | |
DatabaseReference mDatabase = FirebaseDatabase.getInstance().getReference(); | |
mDatabase.child("users").child(App.get().getUid()).child("items").addValueEventListener(new ValueEventListener() { | |
@Override | |
public void onDataChange(DataSnapshot dataSnapshot) { | |
// THIS IS FIRING. ALL GOOD | |
} | |
@Override | |
public void onCancelled(DatabaseError databaseError) { | |
... | |
} | |
}); | |
// ############################################################################## | |
// After this I change code to following and it works | |
// ############################################################################## | |
FirebaseDatabase.getInstance().setPersistenceEnabled(true); | |
FirebaseDatabase.getInstance().goOffline(); // <--------NOTE THIS | |
DatabaseReference mDatabase = FirebaseDatabase.getInstance().getReference(); | |
mDatabase.child("users").child(App.get().getUid()).child("items").addValueEventListener(new ValueEventListener() { | |
@Override | |
public void onDataChange(DataSnapshot dataSnapshot) { | |
// THIS IS FIRING. ALL GOOD | |
} | |
@Override | |
public void onCancelled(DatabaseError databaseError) { | |
... | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment