Skip to contents

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 NULL for all the fields that exist when rewind takes the snapshot.

id

A name for this group. rewind uses it to keep the registered objects apart, and to label the history entries. The default is the name of the values argument at the call.

session

The Shiny session. The default is the current session.

Value

TRUE, invisibly.

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"))
  }
}