{"id":18240969,"url":"https://github.com/rpodcast/shinystate","last_synced_at":"2025-04-04T09:31:04.487Z","repository":{"id":258328364,"uuid":"789849209","full_name":"rpodcast/shinystate","owner":"rpodcast","description":"Extensions on shiny bookmarkable state","archived":false,"fork":false,"pushed_at":"2025-01-14T05:20:37.000Z","size":445,"stargazers_count":3,"open_issues_count":7,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-26T21:46:00.668Z","etag":null,"topics":["r","shiny"],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rpodcast.png","metadata":{"files":{"readme":"README.md","changelog":"NEWS.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-21T18:08:08.000Z","updated_at":"2024-10-21T18:43:24.000Z","dependencies_parsed_at":"2024-10-21T22:31:40.077Z","dependency_job_id":null,"html_url":"https://github.com/rpodcast/shinystate","commit_stats":null,"previous_names":["rpodcast/shinystate"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rpodcast%2Fshinystate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rpodcast%2Fshinystate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rpodcast%2Fshinystate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rpodcast%2Fshinystate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rpodcast","download_url":"https://codeload.github.com/rpodcast/shinystate/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247152973,"owners_count":20892588,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["r","shiny"],"created_at":"2024-11-05T05:05:56.097Z","updated_at":"2025-04-04T09:30:59.474Z","avatar_url":"https://github.com/rpodcast.png","language":"R","funding_links":[],"categories":["Backend"],"sub_categories":["Persistent Data Storage"],"readme":"# shinystate \u003cimg src=\"man/figures/logo.png\" align=\"right\" height=\"139\" alt=\"\" /\u003e\n\n\u003c!-- badges: start --\u003e\n\u003c!-- badges: end --\u003e\n\n`shinystate` is an R package that provides additional customization on top of the standard Shiny [bookmarkable state](https://shiny.posit.co/r/articles/share/bookmarking-state/) capabilities.\n\n## Installation\n\nYou can install the development version from GitHub with the remotes package:\n\n```r\nremotes::install_github(\"rpodcast/shinystate\")\n```\n\n## Why `shinystate`?\n\nIf your Shiny application leverages bookmarkable state and the default feature set is working for your use case, then `shinystate` is likely not value-added. \n\nHowever, as applications grow in complexity and are used in high-stakes situations, you may wish your application could support the following features:\n\n* Flexible configuration of where bookmarkable state files are stored, whether on the same file system as the server running the application, or in a separate repository such as cloud storage.\n* Allow users to save multiple bookmarkable state sessions, tailored to situations such as multiple \"projects\" inside the same application.\n* Augment the bookmarkable state artifacts with metadata of your choosing. Possible metadata could include custom names and timestamps.\n \nThe `shinystate` package offers an intuitive class system built upon the `R6` package with methods tailored to the common operations with managing bookmarkable state. \n\n## Basic Usage\n\nHere is the general setup procedure for incorporating `shinystate` in your Shiny application:\n\n* Load the package in your application with `library(shinystate)` or other methods used in frameworks such as `golem` or `rhino`.\n* Create a new storage class object in the beginning of your application with `StorageClass$new()`. Optional parameters exist and are discussed in the detailed user guides.\n* Inside the user interface function of your application, add `use_shinystate()`.\n* Inside the server function of your application, execute the `register_metadata()` method.\n* Add a call to `shiny::enableBookmarking(\"server\")` either in the server function or as part of a custom function used for the `onStart` parameter in `shiny::shinyApp()`.  \n\nOnce the setup is complete, you can use the following methods with the storage object to perform common operations:\n\n* `snapshot()`: Save the state of the application as a set of bookmarkable state files.\n* `restore(url)`: Restore a previously-saved state based on the unique URL of the snapshot\n\nHere is an example Shiny application inspired by the single-file example from the official [introduction to bookmarking state](https://shiny.posit.co/r/articles/share/bookmarking-state/) article that utilizes `shinystate`:\n\n```r\nlibrary(shiny)\nlibrary(shinystate)\n\nstorage \u003c- StorageClass$new()\n\nui \u003c- function(request) {\n  fluidPage(\n    use_shinystate(),\n    textInput(\"txt\", \"Enter text\"),\n    checkboxInput(\"caps\", \"Capitalize\"),\n    verbatimTextOutput(\"out\"),\n    actionButton(\"bookmark\", \"Bookmark\"),\n    actionButton(\"restore\", \"Restore Last Bookmark\")\n  )\n}\n\nserver \u003c- function(input, output, session) {\n  storage$register_metadata()\n  output$out \u003c- renderText({\n    if (input$caps) {\n      toupper(input$txt)\n    } else {\n      input$txt\n    }\n  })\n\n  observeEvent(input$bookmark, {\n    storage$snapshot()\n    showNotification(\"Session successfully saved\")\n  })\n\n  observeEvent(input$restore, {\n    session_df \u003c- storage$get_sessions()\n    storage$restore(tail(session_df$url, n = 1))\n  })\n\n  setBookmarkExclude(c(\"bookmark\", \"restore\"))\n}\n\nshinyApp(ui, server, onStart = function() {\n  shiny::enableBookmarking(\"server\")\n})\n```\n\n## Code of Conduct\n\nPlease note that the shinystate project is released with a [Contributor Code of Conduct](https://contributor-covenant.org/version/2/1/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frpodcast%2Fshinystate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frpodcast%2Fshinystate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frpodcast%2Fshinystate/lists"}