Multiple conditions for eventReactive

I'm curious, is is better to use multiple conditions to trigger an event, or is it better to use the if statement as I have in the pseudo code below to illustrate. I have actually run my real code both ways, and it seems to yield an identical result.

Are they both identical, or does one prove to be better in practice?

myObject <- eventReactive(input$runModel, {
if(input$run.dictionary){
do stuff ...
} #end if
})

myObject <- eventReactive(
{input$runModel
input$run.dictionary},
{
do stuff ...
})

I don't think they would yield the same result.

In the first case, the reactive expression would only get run when input$runModel gets invalidated. If input$run.dictionary is updated, the code will not get run.

You do need to put both of them in a list together as the first argument of eventReactive() if you want the reactive expression to trigger when either one of them updates.

2 Likes