# Reactivity: composed reactive variable

Whenever the value of a reactive variable (or an input) changes, the code that uses this reactive variable is re-executed. To determine what code runs when a reactive variable changes its value, Shiny creates a dependency graph from the code. In general, if x depends on y and y depends on z, then modifying z causes y to update, which in turn triggers x to update.

Here is an example of a reactive variable that depends on another reactive variable:

x <- reactive({
input$num1 + 5 }) y <- reactive({ x() + input$num2
})


In the code above, when does the value of y get updated?