0

As already stated here, I got a question regarding the concurrent connections. In the documentation is stated, that values can (and mostly should) be retreived with ref.on('child_added')

Let's say we have a simple list of friends. Does this mean we have one active connection for said callback and additionally another one for the 'child_removed' event (when someone removes me from their friend list). So we need two callbacks for every data I want to retreive.

This will result in a lot of connections considering things like chat-messages, profile data, and so on, are solved the same way.

Am i misunderstanding the concept,or does this mean that for the 100 free concurrent connections, the limit in a simple chat-application is reached with about 20 users ?

Community
  • 1
  • 1
Thomas
  • 2,375
  • 2
  • 17
  • 32
  • `.on` will be called on **all** actions. So the callback will be triggered for adding, deleting and updating. – camden_kid May 05 '17 at 13:04
  • @camden_kid you mean .on('value',..), right ? – Thomas May 05 '17 at 13:07
  • Yes, ref.on('value'...) – camden_kid May 05 '17 at 13:09
  • @camden_kid but that would imply, all the Data is rertreived with every event. This is even worse, Since 'value' returns the entire Data, not juat the one that changes iirc – Thomas May 05 '17 at 13:13
  • That's true. It suits my purpose but I can see it being a problem with large sets of data. It may be better to update locally and use `.once` to get the initial data. There may be a better way with Firebase though I haven't come across it. – camden_kid May 05 '17 at 13:27
  • 1
    *firebaser here* A single client (browser tab or app instance) keeps at most a single open connection to the Firebase Database servers. See http://stackoverflow.com/a/14307743/209103 – Frank van Puffelen May 05 '17 at 17:26
  • @Frank van Puffelen thats super neat. Thanks for the answer. – Thomas May 05 '17 at 18:45

0 Answers0