Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Meteor: send message to user at hot code push

Tags:

meteor

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?

like image 416
Alveoli Avatar asked Feb 21 '16 13:02

Alveoli


1 Answers

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:

  1. Replace the console.log with an alert modal or something informing the user that the screen is about to reload.

  2. Replace ALERT_DELAY with some number of milliseconds that you think are appropriate for the user to read the modal from (1).


Other notes

  • 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.

like image 197
David Weldon Avatar answered Oct 29 '22 11:10

David Weldon