Reputation: 289
I would like to turn off the automatic app refresh in meteor that occurs every time I change a file. How do I do this?
Upvotes: 12
Views: 4333
Reputation: 9925
There is a small trick for that. Put #
in the end of the url of the page you are working and press Enter
, then continue to work on your code. Once you save the file, page will not be refreshed till you refresh it manually (F5
or cmd + R
) This way will prevent the page to refresh, but the new code is still pushed to the client and you don't need to disable the HCP for the whole site. Disadvantage: you don't know when the new code is pushed to the client
Upvotes: 0
Reputation: 10187
Building on those David's response, here's how I've been doing it to let components stop hot code push while they are alive:
let shouldReloadPage = false;
const componentsBlockingHCP = [];
Meteor._reload.onMigrate(function() {
if (componentsBlockingHCP.length) {
shouldReloadPage = true;
return [false];
}
shouldReloadPage = false;
return [true];
});
/*
* Prevent hot push
*/
export const delayHCP = (component) => {
if (componentsBlockingHCP.indexOf(component) < 0)
componentsBlockingHCP.push(component);
};
/*
* Enable, and reload if hot pushed has been requested when it was not available
*/
export const stopHCPDelay = (component) => {
const idx = componentsBlockingHCP.indexOf(component);
if (idx !== -1)
componentsBlockingHCP.splice(idx, 1);
if (shouldReloadPage && !componentsBlockingHCP.length) {
location.reload();
}
};
And then, from a component (with React syntax):
componentDidMount() {
delayHCP(this);
}
componentWillUnmount() {
stopHCPDelay(this);
}
Upvotes: 4
Reputation: 6147
You can start your app with the --once
flag, like so: meteor --once
.
Upvotes: 19
Reputation: 64312
You can disable HCP (hot code push) by adding this anywhere in your client code:
Meteor._reload.onMigrate(function() {
return [false];
});
After doing that, you'll need to manually refresh the page in order to see any new changes.
Upvotes: 18