16.1 Introduction

This chapter based on Escaping the graph is made to addressing the reactive programming identifying the connections inside the app, and to use reactiveVal() and observe()/observeEvent() functions with the scope of applying manual controls over parts of the graph.

The questions we are going to answer in these notes of the Mastering Shiny book by Hadley Wickham are:

What’s happening inside the app?

How to escape the constraints of the reactive graph?

General usage of the reactiveVal() and observe()/observeEvent() functions is on a small scale, the interaction in bigger pieces results more complicated. A second suggestion is to keep the chunk of code isolated from the rest of the app so that the smallest possible number of observers modify the reactive value.


To recap: Reactive programming is used to specify a graph of dependencies so that when an input changes, all related outputs are automatically updated. The reactive graph describes how inputs and outputs are connected, it is a powerful tool for understanding how your app works, and it’s useful to sketch the dependencies in your graph.

Figure 16.1 shows the diagram of a general app. This is a basic visualization of the app connections, the connections between the reactive components are directional, with the arrows indicating the direction of reactivity.

Figure 16.1: This basic diagram shows the main connections of the app