I am designing an app that contains (a lot of) documents which are shared to (possibly many) groups.
I need to understand how document changes are pushed from the server to the client in order to build my data model.
onSnapshot ?In model (1), the cost of adding many onSnapshot (one for every document) seems low. In model (2), it could be high but it is a burden on the server ? How does all this relate to firestore pricing model (Read counts).
Thanks for any lights on this...
Actually, the answer is in the code:
/**
* A PersistentStream that implements the Listen RPC.
*
* Once the Listen stream has called the openHandler, any number of listen and
* unlisten calls calls can be sent to control what changes will be sent from
* the server for ListenResponses.
*/
export class PersistentListenStream extends PersistentStream< // ...
When we create an onSnapshot, the query is sent to the server which remembers what the client is interested in and updates it's notification filter.
This means that we are in scenario #2 and it explains the cost of open connections for the server.
This also means that we do not care how many onSnapshot we create. Concerning the client, there is no performance issue in doing one onSnapshot for each document we get (but there is a Read cost in Firestore for this).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With