observe(x, env = parent.frame(), quoted = FALSE, label = NULL,
suspended = FALSE, priority = 0, domain = getDefaultReactiveDomain(),
autoDestroy = TRUE, ..stacktraceon = TRUE)
FALSE
.
This is useful when you want to use an expression that is stored in a
variable; to do so, it must be quoted with quote()
.TRUE
, start the observer in a suspended state. If
FALSE
(the default), start in a non-suspended state.TRUE
(the default), the observer will be
automatically destroyed when its domain (if any) ends.stacktrace
.suspend()
resume()
destroy()
setPriority(priority = 0)
setAutoDestroy(autoDestroy)
onInvalidate(callback)
values <- reactiveValues(A=1)
obsB <- observe({
print(values$A + 1)
})
# Can use quoted expressions
obsC <- observe(quote({ print(values$A + 2) }), quoted = TRUE)
# To store expressions for later conversion to observe, use quote()
expr_q <- quote({ print(values$A + 3) })
obsD <- observe(expr_q, quoted = TRUE)
# In a normal Shiny app, the web client will trigger flush events. If you
# are at the console, you can force a flush with flushReact()
shiny:::flushReact()
Run the code above in your browser using DataCamp Workspace