Why Is It Triggering Twice? Understanding Shiny Reactivity
summary
Explains why Shiny reactivity reruns by showing a calories calculator that initially recomputes four slow steps (artificial 1s delays) on every input change, then refactors into focused reactives, adds reactiveVal vs reactive and observer patterns to stop unnecessary invalidations, uses isolate() and observeEvent(ignoreInit) to prevent startup double-runs, reads/saves user settings via cookies (causing an extra init run until debounced), and applies bindCache so repeated gender/activity lookups drop from ~2s to ~1s; demonstration runs and performance wins are shown with concrete timings.
AI-written summary · about
chapters (11)
- 0:00Introduction to reactivity
- 12:33Core reactive elements
- 27:31Reactives in production lines
- 39:26Reactive vs reactiveVal
- 51:17Unexpected triggers and isolate
- 1:02:31Reading from cookies
- 1:12:58Break and recap
- 1:22:41Controlling execution with rack and bounce
- 1:32:06Removing the action button
- 1:41:11Optimizing reactivity with bindCache
- 1:47:42Best practices summary
