Meteor automatic update upon application reload

Meteor automatically updates all tabs for all connected clients when the server restarts. I need to control this functionality so that it updates more slowly and gives a notification about what is happening.

I found the code in the source in the liveata package, but is there any way to control it without breaking the main package.

+4
source share
1 answer

There is a private API in the /reload/reload.js package to do this. Since the API is private, it can change, but here's how it works:

Example:

if (Meteor.isClient) { var firstTime = true; function onMigrate (retry) { if (firstTime) { console.log("retrying migration in 3 seconds"); firstTime = false; Meteor.setTimeout(function () { retry(); }, 3000); return false; } else { return [true]; } } Meteor._reload.onMigrate("someName", onMigrate); // or Meteor._reload.onMigrate(onMigrate); } 

From the comments in packages/reload/reload.js :

Packages that support migration must be registered by calling this function. When it migrates, the callback will be called with one argument, the "repeat function". If the package is ready to migrate, it should return [true, data], where the data is its data migration, an arbitrary JSON value (or [true] if it does not have migration data this time). If the package has more time before it is ready to migrate, it should return false. Then, once it is ready to migrate again, it should call the snooze function. The snooze function will return immediately, but plan to re-migrate that each packet will be tried again to migrate the data. If they are all ready this time, then migration will occur. the name must be set if there is migration data.

+2
source

All Articles