3

This is a follow-up for my previous question Automatically reloading shiny app when add changes.

The solution options(shiny.autoreload = TRUE) works perfect when you want to automatically see changes on the browser which you put in the code.

However, the potential problem occurs when you save unfinished/corrupted file. For example, the following ui code lacks a , sign after the titlePanel function:

fluidPage(

  titlePanel("Old Faithful Geyser Datass")
  sidebarLayout(...

When you save such a file, you will get an error on your browser

ERROR: Error sourcing your_path/ui.R

R console will help detect the problem with the , sign. My impression was that if I improve my code and save the file, it should reload the browser and show my app correctly. Unfortunately, it doesn't do it.

Interesting thing is that an error in the app does not terminate the connection with the browser. To confirm my word, just reload the app manually using reload button in the browser (after improving your code).

Therofore, I examined how this shiny.autoreload option works. As I expected, it checked the time of file modification and then execute reload function. Then reload function send a message via sendMessage to the addMessageHandler:

addMessageHandler('reload', function(message) {
  window.location.reload();
});

So it seems that after improving your code the function should be reexecuted, but it's not gonna happen.

To summarise, I think it's not possible to change it without major changes in shiny but maybe I am wrong. Thanks for any suggestion.

PS.You can manipulate example code here to see the problem.

Nicolabo
  • 1,337
  • 12
  • 30

0 Answers0