Reactivity: effects of isolation
If there is a reactive variable that appears multiple times in your code, and you want to ensure that its modification does not trigger a re-evaluation of the code, you need to isolate all the instances of that variable. That means that if a variable x is inside an isolate() but also appears outside of it, then it will trigger reactivity.
The following code defines a reactive variable result and calculates it using three input values:
result <- reactive({
temp <- input$X + input$Y
isolate({
temp <- temp * input$Y * input$Z
})
temp
})
In the code above, when does the result reactive variable get updated?
Este exercício faz parte do curso
Case Studies: Building Web Applications with Shiny in R
Exercício interativo prático
Transforme a teoria em ação com um de nossos exercícios interativos
Começar o exercício