As I keep in mind, in order for us to have a real-time site and make changes to the database for all users at the same time,
Methods must also be entered in the client and defined in the client.
I did not enter these methods in the client, but I still see that the changes are done in real time for all users.
For example, if I create a post in one browser, it will be created quickly in another browser.
While the post creation method is not entered in the client.
Currently, when a change is made to the database in a browser, the change is sent to all clients.
I do not want the whole software to have this function. Because I think the bigger the software, the lower its performance because it takes more resources from the server.
“make changes to the database for all users at the same time, Methods must also be entered in the client and defined in the client” - this is a wrong statement.
Details are here: Methods | Meteor API Docs.
Meteor can use Optimistic UI. You would get the update on your client but not on the other clients.
That can only happen with techs like pub/sub, Streams. etc.
I believe your issue is related to a pub/sub. You could use a Meteor plugin for Chrome and see what subscriptions activate when you do various things. I would assume you already removed unsecure and autopublish packages.
I made a small sample, please run this very small repository and open the application in two browsers.
In this example, when you create a new link, both your ui is rebuilt and the new link is displayed to you in real time, and also the ui of the other clients is rebuilt, and in fact the new link is displayed to them immediately.
This is while I did not enter the method that creates the new link in the client at all. And normally my ui should not be rebuilt and no new data should be sent to other clients.
Hey, I’m not sure if I got your question right because I was not able to open your repository but the fact that you haven’t imported the Meteor methods on the client side it’s not related to having real time updates on different browsers.
When you import methods on the client what you have is optimistic UI, meaning that they will be simulated on the client and each user will get a quicker response because your logic will run on the client using minimongo before running on the server. When the method finish running on the server you get the real result of the operation.
Real time updates are the default way that Meteor works when you use publications and subscriptions.
How to prevent all data from being real-time.
I just need part of the site to be real time.
I think if all the site with all its details is real time, it will be a heavy burden on the server.
And this time with the addition of users, even more
I don’t say it’s better in every cases.
For example when you go to a page, there is a react component there and in that component I call a method, it returns data I need. I don’t have ty select them from the mini mongo, I don’t care if I need to remove them after the component got unmounted.
But when I needed the data sits there for awhile. I would use pub/sub or I would insert them in local collections directly.
It depends on how your app works. There is no best option for all cases.
The problem with this method is that it is not compatible with ssr.
The react-router-ssr package works on a pub / sub basis.
As a result, no ssr is provided on pages where data is captured by methods.