Hello everyone, I’m using realmjs in my react native project for a while and I’m curious do I use it like it was made for or not?
Context
Just to give you basic context of the app I’m working on, it’s a chat app where people can communicate if they enjoy their chat they can add each other to friends and chat forever etc. It has all the basic features of all chats: username, online status, profile picture, message edition/deletion, images, voices etc.
How do I use realm
Client syncs its data with backend and store it in realm (all chats, messages, partners data), so basically all needed data is stored locally on a device in realm and on each app’s launch it fetches missed data from the server.
In many components I add listeners to realm. For example I listen for all chats with friends to show them in ChatList, in each Chat I have a listener on messages, then in each message I have listeners to track status (sending, sent, read), was it deleted or not, was it edited or not etc. I do have indexes and query for indexed field and it works fast enough me.
My concerns
Basically I have two concerns:
- Is it okay to store all data in realm like I do?
- Is is okay to have many many listeners (I clean them up on unmount, so there’re no memory leaks), if a chat has 300 messages then my app will end up with at least 300 realm listeners, I have a feeling that it may hurt the app performance