Socket refresh heads-up

Hi!

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.

Screenshot 2022-06-23 at 16.17.24

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):

So when I want to refresh all users from 1 specific company, I emit to the company room:

Use Direct Message to target just one user

Then in the front-end, you can use the socket component to handle the socket messages for the specific socket events, and run the database refreshes:

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” :sweat_smile:

Community Page
Last updated: