简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM