I am trying to make a chat application based on suggestions in the Firebase documentation about denormalizing.
I have a list of chat rooms the user is part of in the user node like this:
{
"user": {
"chat_ids": {
"room_1_id": true,
"room_2_id": true
}
}
}
and chat node as:
{
"room_1_id": {
"last_posted": "date"
},
"room_2_id": {
"last_posted": "date"
}
}
The chat node has rules that which prevent members who aren't part of a room to read that node. I am getting the list of chat ids from the user node and then getting details of each chat and attaching listeners to each chat child to detect change in them.
My question is in case a user is part of 20+ chat rooms, there will be 20 listeners, so will that cause performance issues? If so is there any alternate way to solve this issue?