Edit an input binding

  1. Let’s run the app without any new Javascript.
library(shiny)
library(OSUICode)

ui <- fluidPage(
  actionButton("button1", icon("plus")),
  actionButton("button2", uiOutput("val")),
  actionButton("reset", icon("undo")),
  plotOutput("plot")
)

server <- function(input, output) {
  output$val <- renderUI({
    paste("Value: ", input$button2)
  })

  output$plot <- renderPlot({
    validate(
      need(
        input$button2 >= 10,
        message = "Only visible after 10 clicks on
        the second button"
      )
    )
    hist(rnorm(100))
  })

  observeEvent(input$reset, {
    if (input$button2 == 0) {
      showNotification(
        "Button successfuly reset",
        type = "warning"
      )
    }
  })
}

shinyApp(ui, server)