Home > Net >  In Firebase Realtime Database, is there an advantage to attaching a .childChanged listener at main n
In Firebase Realtime Database, is there an advantage to attaching a .childChanged listener at main n

Time:11-14

I have a Realtime Database for a card game between players. Sometimes I am seeing logs of clients with disconnected sockets (monitoring with onDisconnect action), and players cannot continue game. My main structure is a game key register with about 14 observers attached to individual children listening for changes/register deletes/register additions.

My next steps I'm looking at to help are:

  1. One observer on game register that listens for child changed, verses having individual children observed.

  2. Using .keepsynced() on observers

  3. Enabling disc persistence

  4. Calling firebase function .goOnline() when client sees it's socket disconnect.

Any advice is appreciated :) Many thanks!

CodePudding user response:

If you register any child_* listener on a parent node, the SDK synchronizes all nodes under that location/query. So if you have many child nodes under a path and only need to monitor a few of them for changes, it may be more efficient bandwidth-wise to monitor the individual child nodes with a value listener on each.

  • Related