What is the equivalent in R-Shiny of the debug mode used in plotly-dash (Python), i.e. when running the app with Dash, we do the following: app.run_server(debug=True). In this way as the app is running on the host, any modification in the source code is mirrored in the opened web page. Is there such an equivalent when running an app in R-Shiny?
Asked
Active
Viewed 710 times
1
-
I don't think so, not automatically. If you have functions in a separate `.R` file and that's what you need updated, then you could use `shiny::reactiveFileReader` on the `.R` file and `source(..., local=env)` where `env` is the environment in which the code was initially loaded. If you need to update `ui` or `server` of the shiny app itself, ... I believe you're out of luck. – r2evans Mar 12 '20 at 14:58
-
2@r2evans please have a look at the option [shiny.autoreload](https://shiny.rstudio.com/reference/shiny/0.14/shiny-options.html). `If TRUE when a Shiny app is launched, the app directory will be continually monitored for changes to files that have the extensions: r, htm, html, js, css, png, jpg, jpeg, gif. If any changes are detected, all connected Shiny sessions are reloaded. This allows for fast feedback loops when tweaking Shiny UI.` – ismirsehregal Mar 12 '20 at 15:35
-
1That's news to me! Thanks @ismirsehregal! That will actually save me some effort during dev. (SK_33, while my first comment is under-informed, I'll keep it there since I believe the suggestion might still have benefit in other contexts.) – r2evans Mar 12 '20 at 15:37
-
2This feature exists since Shiny 0.13.0 (release date: 2016-01-20) - cheers – ismirsehregal Mar 12 '20 at 15:38
-
1Haha, thanks for that slap of reality and shaming, you could have gone one step further to link to the commit that added it ;-) ... (TBH, there are functions in base R that have been there for *decades* that I am still finding ...) (I do *not* need the link to the relevant commit ... just being funny.) – r2evans Mar 12 '20 at 15:39
-
1It wasn't meant that way. I'm of course also learning every day. I just wanted to put it in contrast to the rather new plotly-dash feature. – ismirsehregal Mar 12 '20 at 15:41
1 Answers
1
As mentioned in the comments, all you need to do is setting the global option shiny.autoreload
.
Here is a very simple example on how to use it:
library(shiny)
options(shiny.autoreload = TRUE) # also check shiny.reactlog and shiny.trace for debugging
ui <- fluidPage(
sliderInput(inputId = "mySlider", label = "my super useful Slider", min = 0, max = 10, value = 20)
)
server <- function(input, output, session) {}
shinyApp(ui, server)
For an overview of similar shiny options please see this article.

ismirsehregal
- 30,045
- 5
- 31
- 78