Hi,
I would like to overload/extend the reactive function. The idea is to put some standard information like time consumption, debugging output inside that new function that allows me to better track what is going on.
Right now I am reproducing for each reactive I am creating things like
Two options come to mind. In shiny v1.3.0, (just released), there is a new option of options(shiny.reactlog = TRUE). Run your app like normal, then hit cmd + F3 or ctrl + F3 to open the reactlog. This might help with what is going on. Please look into profvis for code profiling.
If you're looking for a console output of the current execution, look into using debugme.
Example:
ui <- fluidPage(
titlePanel("Hello Shiny!"),
sidebarLayout(
sidebarPanel(
sliderInput("obs", "Number of observations:", min = 1, max = 1000, value = 500)
),
mainPanel(plotOutput("distPlot"))
)
)
server <- function(input, output) {
debugme::debug("app started", pkg = "myshinyapp")
output$distPlot <- renderPlot({
debugme::debug("plot render start", pkg = "myshinyapp")
on.exit({
debugme::debug("plot render end", pkg = "myshinyapp")
})
# generate an rnorm distribution and plot it
dist <- rnorm(input$obs)
hist(dist)
})
}
# enable your application's debugging
Sys.setenv(DEBUGME = "myshinyapp")
shinyApp(ui, server)
❯❯ shinyApp(ui, server)
Listening on http://127.0.0.1:7623
myshinyapp app started +9784ms
myshinyapp plot render start +14ms
myshinyapp plot render end +28ms
myshinyapp plot render start +1999ms
myshinyapp plot render end +34ms
myshinyapp plot render start +2994ms
myshinyapp plot render end +32ms
myshinyapp plot render start +4496ms
myshinyapp plot render end +24ms
There are longer exec times for the start, as it is how long I waited to hit the button to produce a new plot. (They may be ignored.)