Here is the shortest solution I have found so far that does not 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 simply copy this into the client code of your application and change two things:
Replace console.log with a warning signal or some message to the user about the need to reload the screen.
Replace ALERT_DELAY with the number of milliseconds that, in your opinion, are suitable for the user to read the modal from (1).
Other notes
I would recommend watching this video on Evented Mind, which explains what happens in a bit more detail.
You can also read comments in reload source for further enlightenment.
I can imagine a more complex reload logic, especially when you decide when to allow reload. Also see this pacakge for one possible implementation.
source share