Might be obvious to most, but I made the mistake of using “Refresh Server Action” for everything, which caused big performance issues. When developing, it’s all fine as you’re the only one testing the app, but when I started to have more users I noticed the problem.
When I wanted to refresh data for 1 user, and I used “Refresh Server Action”, it was obviously refreshing ALL user’s api’s, which basically froze the app for everyone.
So when a refresh is needed:
Use Emit for a group of users that you want to target (for example if all users within a company need an update):
In my case when a user connects, it connects to the room of his company id
So when I want to refresh all users from 1 specific company, I emit to the company room:
When a user connects to the app, I update a database table with the user’s socket id, which I look up when needed and send a direct message to only his socket id
So again, probably obvious, but I wanted to spare you the time of re-doing all this like me in case you just got started with developing with only the “Refresh server action”
Hi, I would really appreciate your help here guys.
I really trying to get this works.
How to config the Join and where?
When the connect and disconnect are execute?
For example, how to update a API just like Refresh Server Action only to a specific group like same busines_id?
In the Frontend, how to update the API when the “emit” send to the update order. In Refresh Server Action we only enabled in Dynamic Attributes the Live Refresh with Socket. How to get similar behiviour using , join, emit and etc…
The same of other Sockets module like, Leave Room, Get Joined Rooms and Get All Rooms, how they works and how to use them to don’t fall into the performance issue by the Refresh Server Action.