Meteor: send a message to the user by clicking on the hot code

How can I tell the user when they click the hot code?

At the moment, the screen will be blank when pressed, and the user will feel it is rather strange. I want to assure them that the application is being updated.

Is there a hook or something that I can use?

+5
source share
2 answers

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.

+3
source

You can send something to Meteor.startup () in your client code. I personally use Bert for toast.

0
source

Source: https://habr.com/ru/post/1243504/


All Articles