Understanding /lib vs /server

Hi all, I have a complex, server intensive code to run.

I have a /server/main.js that iterates over ALL users and checks for certain conditions. Would this then mean, any changes would be pushed down the pipe on a reactive data publication, taking up bandwidth as those changes are pushed to each and every individual client.

So, if I instead move to /lib/main.js and run the same code, would it then ‘emulate’ on the clients, and save bandwidth? Only pushing that data when there is some difference, and allowing the application to run more ‘lag free’ seemingly?

However, while on the /lib/main.js – on the client, it will not have access to ALL the data, as the server would. So this would kind of de-sync the system right? So therefor, I have no choice but to leave it on /server?

Emulating on the client only gives you the benefit of updating the UI immediately. The work will always be done on the server and all changes will be sent to clients regardless of if it agrees with the emulated result or not

2 Likes

Fantastic, thanks for clearing that up. So I may as well just work in /server for the time being… Hrmmm… Yes interesting…