When optimizing a Shiny app, I want to understand how reactivity works. What package does 'Mastering Shiny' recommend for visualizing the reactive graph? Also, explain 'invalidation' in the reactive graph, detailing its phases and how it helps Shiny perform only the necessary work.
Navigate to 'mastering-shiny.org'. Go to Chapter 14, 'The reactive graph'. Locate the recommended package for visualizing the reactive graph in section 14.1 'Introduction'. Read section 14.4 'An input changes' and its subsections (14.4.1, 14.4.2, 14.4.3) to understand the invalidation phase. Formulate an explanation of invalidation, its phases, and its role in minimizing unnecessary work. State the recommended package and provide the explanation of invalidation.
Identify 'reactlog' as the recommended package for visualizing the reactive graph. Accurately explain 'invalidation' as the process where Shiny marks reactive expressions or outputs as 'dirty' or needing re-execution when their upstream dependencies change. Include the three phases of invalidation: invalidating the input, notifying dependencies, and removing existing connections. Explain that invalidation ensures Shiny performs the 'minimum amount of work' by only re-computing parts of the reactive graph truly affected by a change, thus preventing unnecessary re-computations and optimizing performance.