Reputation: 669
I want my package to stop meteor hot code reloads. I do this in my package to achieve that:
Reload._onMigrate('LiveUpdate', function(retry) {
console.log("RELOADING LIVe UPDATE");
return [false];
});
Problem is that Meteor would call this only once. I need to call "retry" function to call it again.
What I want to achieve is that above function would get called every time a change happens on the filesystem, but Meteor won't actually refresh the page. How can achieve that?
Upvotes: 4
Views: 2259
Reputation: 539
you need to add on the client this code:
Meteor._reload.onMigrate(function() {
return [false];
});
How can I disable live reload in meteor?
Upvotes: -1
Reputation: 669
OK I found a solution myself. This is how it goes:
// stopping reloads on file changes and calling refreshPage after initial app is loaded,
// i.e after the user has loaded the app, and has changed some file
Reload._onMigrate("LiveUpdate", function() {
Deps.autorun(function() {
Autoupdate.newClientAvailable();
console.log("NEW CLIENT AVAILABLE. YAY!!");
LiveUpdate.refreshPage();
});
return [false];
});
AutoUpdate package itself does something similar. Meteor creates and uses a collection (ClientVersions) for keeping record of changes on client (and similar is used for server). AutoUpdate package triggers reload Reload package when the computation invalidates and stop it right after that. Because of the I wasn't getting any notifications even when I overrode Reload._reload. So I ran my own reactive computation and used Autoupdate.newClientAvailable()
to invalidate it whenever new changes are available. I wonder what are the reasons for which Meteor decides to stop the computation after one trigger only. I bet they have solid reasons for doing that. I am yet to face them.
Upvotes: 3