I have configuration options for a shiny app that are behind a panel. Moreover, the configuration options are generated server side using uiOutput/renderUI. Shiny defers evaluation of items that are not in the currently selected panel, but sometimes it's desirable to force evaluation. Is it possible to force server side evaluation?
Here's an example:
library(shiny)
ui <- fluidPage(
tabsetPanel(tabPanel("Main",
plotOutput("dots")),
tabPanel("Settings",
uiOutput("even.or.odd")
)
)
)
server <- function(input, output) {
output$dots <- renderPlot({
plot(seq(ifelse(input$even, 0, 1), 20, 2))
})
output$even.or.odd <- renderUI(checkboxInput('even', "Even?",TRUE))
}
shinyApp(ui = ui, server = server)
Or from RStudio do runGist('https://gist.github.com/dkulp2/d897c21dfd1a20f9531b6454ea02a533')
This fails on startup because input$even
is undefined until the "Settings" panel is revealed. (And then the app works fine.) Is there some way to cause Shiny to evaluate the even.or.odd
function without revealing the panel?