Reputation: 1202
How can I let the user know when they are getting a hot code push?
At the moment the screen will go blank during the push, and the user will feel it's rather weird. I want to reassure them the app is updating.
Is there a hook or something which I can use?
Upvotes: 6
Views: 9578
Reputation: 64312
Here's the shortest solution I've found so far that doesn't require external packages:
var ALERT_DELAY = 3000;
var needToShowAlert = true;
Reload._onMigrate(function (retry) {
if (needToShowAlert) {
console.log('going to reload in 3 seconds...');
needToShowAlert = false;
_.delay(retry, ALERT_DELAY);
return [false];
} else {
return [true];
}
});
You can just copy that into the client code of your app and change two things:
Replace the console.log
with an alert modal or something informing the user that the screen is about to reload.
Replace ALERT_DELAY
with some number of milliseconds that you think are appropriate for the user to read the modal from (1).
I'd recommend watching this video on Evented Mind, which explains what's going on in a little more detail.
You can also read the comments in the reload source for further enlightenment.
I can image more complex reload logic, especially around deciding when to allow a reload. Also see this pacakge for one possible implementation.
Upvotes: 4
Reputation: 4049
You could send something on Meteor.startup() in your client-side code. I personally use Bert to toast messages.
Upvotes: 0