Determine which input was updated.

If I have a reactive expression (like the contents of a renderXXX() function) that depends on multiple inputs or other reactive values, is there any way to determine which value's update is causing the reaction in the reactive expression? For example, if you have an output whose rendering function involves the values of two different inputs, is there a simple/convenient/built-in way to determine which of those two inputs is changing and thus causing the rerender of the output?

Right now I have something like this (this isn't a reprex exactly, because I don't have a bug):

the_value <- reactiveVal(
    list(source = NULL, value = NULL)
)

observe(
    the_value(
        list(source = "one", value = input$one)
    )
)
observe(
    the_value(
        list(source = "two", value = input$two)
    )
)

output$the_output <- renderText({
    val <- the_value()
    if(val$source == "one") {
        paste("value from one", val$value)
    } else {
        paste("value from two", val$value)
    }
})

I'm hoping there exists something akin to (borrowing the idea of selecting from other polling situations):

output$the_output <- renderText({
    select(
        case(input$one, paste("value from one", input$one)),
        case(input$two, paste("value from two", input$two))
    )
})

Or is what I have already what I get?

Thanks.

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.