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?
Diese Übung ist Teil des Kurses
Case Studies: Building Web Applications with Shiny in R
Interaktive Übung
Setze die Theorie in einer unserer interaktiven Übungen in die Praxis um
