aldeed:reload-extras
A client-side Meteor package that provides extra features for the core reload
package.
Installation
$ meteor add aldeed:reload-extras
Reload.isHotReloading
This will be set to true
when a hot reload is occurring. This is useful when you want to prompt before closing the tab or refreshing, but only when it is not a hot reload.
In client code:
1$(window).on('beforeunload', function () { 2 if (!Reload.isHotReloading) { 3 return 'Are you sure you want to exit the app?'; 4 } 5});
Reload.didHotReload
This will be set to true
when client code is running after a hot reload. Use this to do setup or show messages upon first loading the app, but only if it wasn't a hot reload.
In client code:
1if (!Reload.didHotReload) { 2 Meteor.call('userEnteredRoom'); 3}
Reload.delay and Reload.beforeHook
To delay a bit while showing a message before hot reloading:
1if (isProduction) { 2 Reload.delay = 5000; //ms 3 Reload.beforeHook = function () { 4 showAlert("In 5 seconds we're going to refresh the app to give you the latest features."); 5 }; 6}