Using the observeEvent Function

But if we need to isolate many variables in a script is better to use observeEvent(x, y) which is equivalent to observe({x; isolate(y)}) to get the same results.

observeEvent(r$x, { 
  r$count <- r$count + 1 
}) 

r$x <- 8
r$count
#> [1] 4

eventReactive(x, y) on the other hand is equivalent to use reactive({x; isolate(y)})