Is it possible to disable a button in shiny while a plot / a reactive element is loading? I know shinyjs
can disable and enable input elements, but I don't know how to set up the connection to a loading plot / reactive element. The example is based on the Single-file shiny apps page. I just added a button and the isolated part. Solutions that are not based on shinyjs
are also appreciated :)
library(shiny)
server <- function(input, output) {
output$distPlot <- renderPlot({
input$button
isolate(
hist(rnorm(input$obs), col = 'darkgray', border = 'white')
)
})
}
ui <- fluidPage(
shinyjs::useShinyjs(),
sidebarLayout(
sidebarPanel(
sliderInput("obs", "Number of observations:", min = 10, max = 500, value = 100),
actionButton("button", "OK!")
),
mainPanel(plotOutput("distPlot"))
)
)
shinyApp(ui = ui, server = server)