Server logic for the replay timeline module. Reads the change history from
the master Automerge document created by sync_inputs(), reconstructs
snapshots at each step, and pushes the values to widgets.
Arguments
- id
Module ID (must match the ID used in
replay_ui()).- doc_id
Document identifier. Must match the
doc_idused insync_inputs(). Default is"default".- replaying
The
reactiveValreturned bysync_inputs().- show_messages
Whether to display commit messages. Default is
TRUE.- playback_ms
Interval in milliseconds between steps during animated playback. Default is
1000.
See also
Other sync:
replay_ui(),
sync_inputs()
Examples
if (interactive()) {
ui <- shiny::fluidPage(
shiny::selectInput("dist", "Distribution",
c("Normal", "Uniform", "Exponential")),
shiny::sliderInput("n", "Observations", 10, 500, 100),
shiny::plotOutput("plot"),
replay_ui("timeline")
)
server <- function(input, output, session) {
replaying <- sync_inputs()
replay_server("timeline", replaying = replaying)
output$plot <- shiny::renderPlot(
hist(switch(input$dist,
Normal = rnorm(input$n),
Uniform = runif(input$n),
Exponential = rexp(input$n)
))
)
}
shiny::shinyApp(ui, server)
}