observeEvent for dynamic list

I can write a handler for multiple static sources:

  observeEvent(list(input$surname, input$firstname), {
    print(input$surname)
    print(input$firstname)
  })

What is the syntax, when I have a dynamic list generated from a database, something like (fails)

myfields = list("firstname", "surname")
observeEvent(input[[myfields]], ....)

And how do I find the input field(s) that actually changed in the handler?

I would create an intermediate reactive value using reactive. And look into using observe to set multiple values at once.

I've made a lot of guesses below, but hopefully it can get you on the right track.

dynamic_data <- reactive({
  getData(input$someInputValue)
})

val1 <- reactiveVal()
val2 <- reactiveVal()

observe({
  dt <- dynamic_data()
  req(!is.null(dt)) # require data to exist
  val1(dt[[1]])
  val2(dt[[2]])
})

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.