Not exactly an app in the wild, but the 3rd pattern here seems to be exactly what you want.
By now, the documentation recommends replacing observeEvent() with bindEvent(), which also has nice ignoreNULL and ignoreInit options (see the manpage for details), so something like that should do what you want:
library(shiny)
library(tidyverse)
dat1 <- data.frame(x = 1:3,
y = 5:7)
dat2 <- data.frame(x = 1:3,
y = 7:5)
accepted_data <- c("dat1", "dat2")
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
selectInput("dataSelect", "Select data", accepted_data),
actionButton("submitButton", "Submit")
),
mainPanel(
plotOutput("myPlot"),
width = 3
)
)
)
server <- function(input, output, session) {
mydata <- bindEvent(reactive(eval(as.name(input$dataSelect))),
input$submitButton,
ignoreInit = TRUE)
output$myPlot <- renderPlot({
ggplot(mydata()) +
geom_point(aes(x,y))
})
}
shinyApp(ui = ui, server = server)