I have an app with two observeEvent() handlers reacting to input A and input B and doing some stuff. Among the stuff for event A, is updating input B.
shinyApp(
ui = fluidPage(
selectInput("A", "Input A", c(1:5)),
selectInput("B", "Input B", c(6:10))
),
server = function(input, output, session) {
observeEvent(input$A, ignoreInit = TRUE, {
message("Doing A stuff")
updateSelectInput(session, "B", selected = 10)
})
observeEvent(input$B, ignoreInit = TRUE, {
message("Doing B stuff")
})
}
)
So changing input A obviously triggers event B as well. I would like event B to be triggered only when the user is changing the value of the input and not when it is done by updateInput. Is there a way to suspend scheduling events when a expression is evaluated? I would like something like this:
shinyApp(
ui = fluidPage(
selectInput("A", "Input A", c(1:5)),
selectInput("B", "Input B", c(6:10))
),
server = function(input, output, session) {
observeEvent(input$A, ignoreInit = TRUE, {
message("Doing A stuff")
suspendEventScheduling()
updateSelectInput(session, "B", selected = 10)
resumeEventScheduling()
})
observeEvent(input$B, ignoreInit = TRUE, {
message("Doing B stuff")
})
}
)
Documentation for observers mentions "suspended state" but I cannot find any examples as to how to actually use it.