| reactiveVal {tabler} | R Documentation |
Reactive Value
Description
A single mutable reactive value. Call with no argument to read (tracks the caller as a dependent); call with one argument to write (invalidates all current dependents).
A named collection of reactive values similar to a reactive list.
Access with rv$name (reactive read) or rv$name <- val (reactive write).
Returns a plain list snapshot of a reactiveValues
object's current values, establishing a reactive read dependency on each
contained value, similar to shiny::reactiveValuesToList().
A lazy, cached computation that re-evaluates only when its reactive dependencies are invalidated.
Stops execution of the current reactive expression, observer,
or render function if any argument is not "truthy" (i.e. is NULL,
NA, FALSE, an empty string, or an empty vector), similar to
shiny::req(). Unlike a normal error, this stop is silent: an
observe()/observeEvent() block simply does nothing for this
run, and a render function (renderUI, renderText, ...)
simply leaves its output unchanged, instead of showing an error.
Any reactive reads inside expr are not registered as
dependencies of the current context.
Eagerly re-runs expr whenever its reactive dependencies
change.
Runs handlerExpr whenever eventExpr changes.
A reactive expression that recomputes valueExpr only
when eventExpr changes, similar to shiny::eventReactive().
Modifies a reactive expression created by reactive
so that it only (re)executes when the given event expression(s) change,
similar to shiny::bindEvent(). Typically used with the pipe:
reactive({...}) |> bindEvent(input$go).
Configure package-wide options for tabler. Currently this
only sets the cache backend used by bindCache, mirroring
shiny::shinyOptions(cache = ...).
Persistently caches a reactive expression's value, keyed by
one or more key expressions, similar to shiny::bindCache().
Unlike reactive's built-in caching (in-memory, lost as
soon as its dependencies change), bindCache() stores values in
the cache backend configured via tablerOptions (e.g.
tinycache::dcache()), so identical key combinations are served
instantly - even across app restarts or different sessions - without
re-running x. Typically used with the pipe:
reactive({...}) |> bindCache(key1, key2) |> bindEvent(input$go).
Call once inside the server function to enable two-way URL parameter synchronisation: the URL query string initialises inputs on page load, and every subsequent input change updates the URL in-place (no page reload, no browser-history spam).
Usage
reactiveVal(value = NULL)
reactiveValues(...)
reactiveValuesToList(x, all.names = FALSE)
reactive(expr)
req(..., cancelOutput = FALSE)
isolate(expr)
observe(expr)
observeEvent(eventExpr, handlerExpr, ignoreInit = TRUE)
eventReactive(eventExpr, valueExpr, ignoreNULL = TRUE, ignoreInit = TRUE)
bindEvent(..., ignoreNULL = TRUE, ignoreInit = TRUE)
tablerOptions(cache)
bindCache(x, ...)
syncUrl(session, exclude = character(0L))
Arguments
value |
Initial value. |
... |
One or more (unevaluated) key expressions. Whenever their
combined value changes, x is (re)computed and the result is
cached; otherwise the previously cached value is returned directly,
without calling x again.
|
x |
A reactive expression created by reactive.
|
all.names |
Include names starting with a dot (default FALSE).
|
expr |
Expression with side effects. |
cancelOutput |
Ignored (kept for signature compatibility with Shiny). |
eventExpr |
Reactive expression whose change triggers re-evaluation. |
handlerExpr |
Expression to run when the event fires. |
ignoreInit |
If TRUE (default), x is not computed until
an event expression first changes (e.g. an actionButton's click counter
starts at 0, not NULL, so without this, x would
compute once immediately on creation, before any click).
|
valueExpr |
Expression to evaluate (and cache) when the event fires. |
ignoreNULL |
If TRUE (default), do not (re)compute while all
event expressions evaluate to NULL.
|
cache |
A tinycache cache object (e.g.
tinycache::dcache(dir = "/path/to/cache") or
tinycache::mcache()) used to store bindCache
values. If never set, an in-memory tinycache::mcache() is
created and used automatically - which (like a plain
reactive) does not survive an R restart. Pass a
dcache() object to persist values across app restarts and
sessions.
|
session |
The session object passed by tablerApp
to the server function.
|
exclude |
Character vector of input IDs to omit from the URL. Action buttons are always omitted regardless of this setting. |
Details
The resulting URL is clean and quote-free, e.g.
http://localhost:3000/?dataset=mtcars&n_rows=10&stat=mean
Sharing or bookmarking that URL restores the exact input state.
Value
A function that acts as getter/setter.
An environment of class "ReactiveValues".
A named list.
A zero-argument function returning the cached value.
The last argument, invisibly, if all checks pass.
The result of expr.
An invisible observer handle with $suspend() / $resume().
A zero-argument function returning the cached value.
A new zero-argument function returning the cached value.
Invisibly, the previous options (as a named list, for restoring later).
A new zero-argument function returning the (possibly cached) value.
Invisibly, session (for chaining).