Skip to content Skip to sidebar Skip to footer

Angular Firebase Listen To Foreach Changes With Subscribe

I am subscribing to get user chats and then for each chat, I am subscribing to two other observables. get_user_chat(chat) { let user = this.firebase.get_user_by_uid(chat.key).s

Solution 1:

I highly recommend modeling each chat room as a collection in Firestore. That way, if you have a chat room/collection for the chat between Brendan and Holly, you're only reading from a single collection, instead of two. That also makes it much easier to keep the messages in the correct order, since you can use a single query to get them.

For an example of this see Best way to manage Chat channels in Firebase. While this question is about Realtime Database, the same logic can be applied to Cloud Firestore.

Post a Comment for "Angular Firebase Listen To Foreach Changes With Subscribe"