Running reactive functions over time (execution scheduling)

The core of the Shiny application is the reactive engine, which tells Shiny when to execute each component. We are now familiar with the reactive flow of various components. Reactive observers have a flag that indicates whether they have been invalidated. Whenever the values of the input object change, all of the descendants in that graph are invalidated. Such invalidated observers are also called dirty or clean. Along with this, the arrows in the flow diagram that have been followed are removed.

Let's discuss an example of a single reactive source and endpoint:

server<- function(input, output) { 
output$Plot_output<- renderPlot({ 
hist(rnorm(input$User_input)) 
  }) 
} 

The flow diagram is as follows:

As soon as the input values change, all the descendants are invalidated and a flush event is triggered:

This is represented in the following diagram, in which the output object is shown in dark grey. When this happens, all the invalidated observers are re-executed. If the output object re-executes, it accesses the reactive value. This makes the output object dependent on the input:

From the preceding graph, we can see that output$Plot_out is requesting for input. Once it gets input, the invalidating flag is cleared and the output is placed on the UI:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset