Skip to content

Instantly share code, notes, and snippets.

@gtm19
Created April 10, 2020 15:27
Show Gist options
  • Save gtm19/d79ea369937a49cab2c1cb24298040d8 to your computer and use it in GitHub Desktop.
Save gtm19/d79ea369937a49cab2c1cb24298040d8 to your computer and use it in GitHub Desktop.
library(shiny)
shiny::shinyApp(
ui = sidebarLayout(
sidebarPanel(
actionButton("one", "One"),
actionButton("two", "Two"),
actionButton("three", "Three"),
actionButton("four", "Four")
),
mainPanel(verbatimTextOutput("view"))
),
server = function(input, output, session){
button_cache <- reactiveVal({
rep(FALSE, 4)
})
selected <- reactiveVal()
buttons <- reactive({
c(input$one,
input$two,
input$three,
input$four)
})
observe({
selected(
as.logical(
buttons() - isolate(button_cache())
)
)
button_cache(
buttons()
)
})
output$view <- renderPrint({
selected()
})
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment