observe() Function

Observers and Outputs use observe().

observe() sets up a block of code that is run every time one of the reactive values or expressions it uses is updated.

y <- reactiveVal(10)
observe({
  message("`y` is ", y())
})
#> `y` is 10

y(5)
#> `y` is 5
y(4)
#> `y` is 4