observe() Propertites

Every time you run the observe() function it creates an action that can be triggered.

In the next example, every time x changes, it creates another observer, so its value is printed another time.

x <- reactiveVal(1)
y <- observe({
  x()
  observe(print(x()))
})
#> [1] 1
x(2)
#> [1] 2
#> [1] 2
x(3)
#> [1] 3
#> [1] 3
#> [1] 3

You should only ever create observers or outputs at the top-level of your server function.