0
votes

I have Room object that has some properties like Title and Description. It also has a property called Players which is a string array of users uids.

In Firestore, I've set Players as a subcollection of my Room document.

I get Room data by using this:

 getRooms(): Observable<Room[]> {
    return this._db.collection<Room>('rooms').valueChanges();
  }();

When I subscribe to this, it of curse, does not know if something happened in the Players subcollection.

Is there a way I can add some code to also listen for the changes in the Players subcollection.

Ideally, I would like to subscribe once and listen for changes in either my Rooms/Room Document or in my Rooms/Room/Players subcollection.

1
maybe you are looking for a way to subscribe multiple observables? - rmjoia
Yes, looks like I will have to do that. Initially, I had Players be a Room property but I've changed my approach and made it a subcollection so now I have to deal with this hurdle :) - user8360241

1 Answers

0
votes

Firestore client libraries don't offer this feature. You will have to also have to create a collection reference to each subcollection and add a listener to each one of those. It could be the same listener object for each one, but there is no avoiding referencing each subcollection by name.