'Individual Listeners for Chat Room List Firestore

I'm trying to implement a chat message service in my iOS application.

Currently, I have a tableview holding different chat rooms for each cell. However, it seems really really slow attaching listeners to each one of them. For example, if a user has 30 previous chats, I'm basically attaching 30 listeners. And when I go to a different viewcontroller, I detach those listeners. When I come back to this page, I re-attach. I do this because when they get a new message and are already on this view controller, I need to update the view immediately.

Is there a more efficient way of doing this?

Thank you



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source