Gordon Shotwell - Understanding reactive execution in Shiny | PyData Global 2023

Discover the power of reactive execution in Shiny, a framework that infers relationships between components, minimizing re-execution and enabling efficient caching and notification of downstream dependencies.

Key takeaways
  • Reactive execution in Shiny is appealing because it allows for efficient re-executions without needing to manually define callbacks.
  • Shiny’s strategy is to infer relationships between components, building a computation graph, and then using that graph to minimally re-execute the application.
  • Shiny apps use reactive calculations (like reactiveCalc) to represent values, and reactive effects (like reactiveEffect) to mark effects, such as fetching data from a database.
  • Shiny’s reactive graph can help with caching and notify downstream dependencies when upstream parts of the graph change.
  • Shiny’s reactivity is great for applications with complex dynamics and changing user inputs.
  • Streamlit, Dash, and other frameworks may not perform as well in these situations, and programmers may need to manually manage state.
  • Shiny’s reactivity allows for automatic rendering of plots and widgets without needing to manually update state.
  • The tourism example demonstrates a simple Shiny app that changes its behavior based on user input.
  • ReactiveIsolate can be used to prevent re-reactions to certain inputs.
  • Shiny has a “range” of capabilities, from simple to complex, and can handle all the layers of a data science application.