phage
phage

Reputation: 588

R Shiny reactive programming: observe versus observeEvent

I am currently creating a Shiny app in R. I have reached the point where I putting more advanced reactive programming into my code. At this point, I am trying to understand how to use the observe function within the reactive context. However, I also encounter another reactive function call observeEvent. What is the difference between observe and obsereEvent in R Shiny?

Upvotes: 0

Views: 1229

Answers (1)

Pork Chop
Pork Chop

Reputation: 29407

observe will trigger anytime there is a reactive dependency inside it, if it's an input, reactiveValues, reactiveVal and so on. The observeEvent and eventReactive will only trigger upon a change that is within the scope of the trigger. Therefore, observeEvent is more conservative than the observe. Moreover, you might have memory leaks if you use observe incorrectly without flushing or rendering the variables inside it. Personally I almost always use observeEvent

Upvotes: 1

Related Questions