I'm trying to get the addSnapshotListener
to fire when a referenced document inside an other document changes.
I have two tables: users
and rooms
.
There is a reference to a user inside rooms
rooms
> {roomId}
> room_users
(which is a collection) > [list of id's]
> reference to a user in each document
Using the following code I get a reference to this
fun getInnerCollection(baseCollection: String, baseDoc: String, collection: String): CollectionReference {
return FirebaseUtil.firestore
.collection(baseCollection)
.document(baseDoc)
.collection(collection)
}
On this I add an addSnapshotListener
.
Any time I change (ar add) a field in any of the documents inside room_users
, the listener fires. However when I changed a property in the users
table, that is linked in a document (like OMF1JtKgj3PZaEsUkitj900FIYm1
in the screenshot), the listener doesn't fire.
Because of this I'm not aware when something changes in a referenced document.
How would I make the listener fire when a change occurs inside a referenced object? Or is adding a listener to every document the only solution?