Learn R Programming

rewind (version 0.4.0)

rewind_exclude: Keep inputs out of the history

Description

rewind_enable(exclude = ) leaves inputs out, but only the code that calls rewind_enable() can set it. This function can be called from anywhere in the server, a module included, at any time. It works like shiny::setBookmarkExclude(): inside a module, give the names that the module uses, and rewind adds the namespace.

Usage

rewind_exclude(
  names = character(0),
  session = shiny::getDefaultReactiveDomain()
)

Value

names, invisibly.

Arguments

names

Character vector of input names, as the calling module uses them.

session

The Shiny session. The default is the current session.

Details

Two things differ from setBookmarkExclude(). A second call adds to the list; it does not replace it, so a module cannot undo an exclusion made elsewhere. And a value already in the history for these inputs is removed, together with any step that changed only them.

A call before rewind_enable() in the same session is kept, and applied when rewind_enable() runs.

Examples

Run this code
if (interactive()) {
  library(shiny)

  search_ui <- function(id) textInput(NS(id, "query"), "Search")
  search_server <- function(id) {
    moduleServer(id, function(input, output, session) {
      # A search box that the user does not expect undo to move.
      rewind_exclude("query")
    })
  }

  ui <- fluidPage(
    rewind_buttons(),
    selectInput("region", "Region", c("North", "South")),
    search_ui("search")
  )

  server <- function(input, output, session) {
    rewind_enable()
    search_server("search")
  }

  shinyApp(ui, server)
}

Run the code above in your browser using DataLab