I am building an application that has a requirement of using a firebase realtime database. I tried using this library but facing some issues. Can someone please confirm if react-native supports firebase totally or it supports with some known bugs.
Issue:
Below are my lines of code:
const reference = database().ref('/');
reference.keepSynced(false);
database().setPersistenceEnabled(true).then() ; // not working as expected, Promise type return is not working.
By default, Firebase will only synchronize a node from the server while you have a listener attached to that node. Setting keepSynced(true)
on a node, ensures that node also gets synchronized when no listener is attached. Setting keepSynced(true)
on a node simply resets it to its default state of only synchronizing data when there's an active listener on the node.
There is no way to not keep a node synchronized when you have a listener attached to it.
By default Firebase keeps an in-memory model of any data it is currently monitoring. When you call setPersistenceEnabled(true)
, this in-memory model is also written to disk, and kept up to date there. I'm not really sure why this call returns a Promise
, as the native methods (like here in Android) do not return anything.