EVOLUTION-MANAGER
Edit File: freezeReactiveValue.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Freeze a reactive value</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for freezeReactiveVal {shiny}"><tr><td>freezeReactiveVal {shiny}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Freeze a reactive value</h2> <h3>Description</h3> <p>These functions freeze a <code><a href="reactiveVal.html">reactiveVal()</a></code>, or an element of a <code><a href="reactiveValues.html">reactiveValues()</a></code>. If the value is accessed while frozen, a "silent" exception is raised and the operation is stopped. This is the same thing that happens if <code>req(FALSE)</code> is called. The value is thawed (un-frozen; accessing it will no longer raise an exception) when the current reactive domain is flushed. In a Shiny application, this occurs after all of the observers are executed. </p> <h3>Usage</h3> <pre> freezeReactiveVal(x) freezeReactiveValue(x, name) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>For <code>freezeReactiveValue</code>, a <code><a href="reactiveValues.html">reactiveValues()</a></code> object (like <code>input</code>); for <code>freezeReactiveVal</code>, a <code><a href="reactiveVal.html">reactiveVal()</a></code> object.</p> </td></tr> <tr valign="top"><td><code>name</code></td> <td> <p>The name of a value in the <code><a href="reactiveValues.html">reactiveValues()</a></code> object.</p> </td></tr> </table> <h3>See Also</h3> <p><code><a href="req.html">req()</a></code> </p> <h3>Examples</h3> <pre> ## Only run this examples in interactive R sessions if (interactive()) { ui <- fluidPage( selectInput("data", "Data Set", c("mtcars", "pressure")), checkboxGroupInput("cols", "Columns (select 2)", character(0)), plotOutput("plot") ) server <- function(input, output, session) { observe({ data <- get(input$data) # Sets a flag on input$cols to essentially do req(FALSE) if input$cols # is accessed. Without this, an error will momentarily show whenever a # new data set is selected. freezeReactiveValue(input, "cols") updateCheckboxGroupInput(session, "cols", choices = names(data)) }) output$plot <- renderPlot({ # When a new data set is selected, input$cols will have been invalidated # above, and this will essentially do the same as req(FALSE), causing # this observer to stop and raise a silent exception. cols <- input$cols data <- get(input$data) if (length(cols) == 2) { plot(data[[ cols[1] ]], data[[ cols[2] ]]) } }) } shinyApp(ui, server) } </pre> <hr /><div style="text-align: center;">[Package <em>shiny</em> version 1.5.0 <a href="00Index.html">Index</a>]</div> </body></html>