I'm trying to run a shiny app locally on my desktop and I'm looking for a way to download and upload the bookmark state as an rds file instead of copying and pasting a url. I've tried workarounds but they are not as helpful as using shiny's bookmark functions and features. Here is an example app which has the bookmark function. I'm trying to convert this into an app that can download and upload rds file to save and restore the state. Any help will be greatly appreciated.
ui <- function(request) {
fluidPage(
sidebarPanel(
sliderInput("n", "Value to add", min = 0, max = 100, value = 50),
actionButton("add", "Add"), br(), br(),
bookmarkButton()
),
mainPanel(
h4("Sum of all previous slider values:", textOutput("sum"))
)
)
}
server <- function(input, output, session) {
vals <- reactiveValues(sum = 0)
# Save extra values in state$values when we bookmark
onBookmark(function(state) {
state$values$currentSum <- vals$sum
})
# Read values from state$values when we restore
onRestore(function(state) {
vals$sum <- state$values$currentSum
})
# Exclude the add button from bookmarking
setBookmarkExclude("add")
observeEvent(input$add, {
vals$sum <- vals$sum + input$n
})
output$sum <- renderText({
vals$sum
})
}
shinyApp(ui, server, enableBookmarking = "url")
This question is also posted here.