I am referring to the solution in this thread here here. The question asks how to implement observeEvent
with multiple events.
My question: using the first reponse (using list
), is there a way to check which event in the input list is triggered, maybe by identifying the input name or its index in the list? The reason I am trying do this is that in my code, the the list of events corresponds to some other list of outputs that I want to modify. Both of these lists are rather long to be implemented with individual observeEvent
.
library(shiny)
ui <- shinyUI(bootstrapPage(
actionButton("test1", "test1"),
actionButton("test2", "test2"))
)
server <- shinyServer(function(input, output) {
toListen <- reactive({
list(input$test1,input$test2)
})
observeEvent(toListen(), {
if(input$test1 is triggered){
do something
} else if (input$test2 is triggered) {
do something else}
})
})
shinyApp(ui, server)