React-native-firebase: Firestore multiple Subscribers

Created on 26 Nov 2017  路  1Comment  路  Source: invertase/react-native-firebase

Hi there, I have a question regarding firestore query subscriptions:

When I add the same listener multiple times - will it fetch the data multiple times or is this somehow handled internally? So I don't want to get multiple updates and especially fetch the same data more often than necessary. Otherwise I would have to track it in an array which subscriber is active.
I need to know this as I have HOCs which register the subscribers on mount and unsubcribe it on unmount. But sometimes the HOC is used mutliple times in the same screen.

Environment

  1. Application Target Platform: Both
  2. Development Operating System: macOS 10.13
  3. React Native version: 0.48.4
  4. RNFirebase Version: 3.0.3
  5. Firebase Module: Firestore

Most helpful comment

@BraunreutherA The native Firestore SDK handles this all for you and minimises traffic across the network. If you add multiple listeners, each will receive updates, but it will only fetch the data from Firestore once.

>All comments

@BraunreutherA The native Firestore SDK handles this all for you and minimises traffic across the network. If you add multiple listeners, each will receive updates, but it will only fetch the data from Firestore once.

Was this page helpful?
0 / 5 - 0 ratings