rewind captures inputs automatically. It cannot see the state that you
keep in a shiny::reactiveValues() object. Register that object here.
rewind then records the registered fields with the inputs, and writes
them back at an undo.
Usage
rewind_track(
values,
fields = NULL,
id = NULL,
session = shiny::getDefaultReactiveDomain()
)Arguments
- values
A
shiny::reactiveValues()object.- fields
Character vector of the field names to track. Use
NULLfor all the fields that exist whenrewindtakes the snapshot.- id
A name for this group.
rewinduses it to keep the registered objects apart, and to label the history entries. The default is the name of thevaluesargument at the call.- session
The Shiny session. The default is the current session.
Details
Register only the values that are true state. A derived value or a cached value does no harm, but it has no use. Do not register a value that an observer computes again immediately. The undo step then appears to do nothing.
Examples
if (interactive()) {
library(shiny)
server <- function(input, output, session) {
rewind_enable()
state <- reactiveValues(selected = character(), zoom = 1)
rewind_track(state, fields = c("selected", "zoom"))
}
}