3.6 Reactive expressions
What - A tool that reduces duplication in your reactive code by introducing additional nodes into the reactive graph
How - using reactive()
# Just for example
server <- function(input, output, session) {
string <- reactive(paste0("Hello ", input$name, "!"))
output$greeting <- renderText(string())
}
In other words, reactive
makes apps cleaner & more efficient (by removing redundant codes & recomputation).
It also simplifies the reactive graph.
Reactive expressions have a flavour of both inputs and outputs:
- Like inputs, you can use the results of a reactive expression in an output.
- Like outputs, reactive expressions depend on inputs and automatically know when they need updating.