Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Appsilon/shiny.worker
Intra-session reactivity in Shiny
https://github.com/Appsilon/shiny.worker
r rhinoverse shiny
Last synced: 3 months ago
JSON representation
Intra-session reactivity in Shiny
- Host: GitHub
- URL: https://github.com/Appsilon/shiny.worker
- Owner: Appsilon
- License: other
- Created: 2020-04-07T12:03:19.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-12-15T02:27:04.000Z (11 months ago)
- Last Synced: 2024-05-15T04:40:38.448Z (6 months ago)
- Topics: r, rhinoverse, shiny
- Language: R
- Homepage: https://appsilon.github.io/shiny.worker/
- Size: 530 KB
- Stars: 58
- Watchers: 26
- Forks: 5
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-shiny-extensions - shiny.worker - Delegate heavy computation tasks to a separate process in a Shiny application. (Developer Tools / Scaling)
- jimsghstars - Appsilon/shiny.worker - Intra-session reactivity in Shiny (R)
README
> _Intra-session reactivity in Shiny._
[![R-CMD-check](https://github.com/Appsilon/shiny.worker/workflows/R-CMD-check/badge.svg)](https://github.com/Appsilon/shiny.worker/actions/workflows/main.yml)
[![cranlogs](https://cranlogs.r-pkg.org/badges/shiny.worker)](https://CRAN.R-project.org/package=shiny.worker)
[![total](https://cranlogs.r-pkg.org/badges/grand-total/shiny.worker)](https://CRAN.R-project.org/package=shiny.worker)`shiny.worker` allows you to delegate heavy computation tasks to a separate process,
such that it does not freeze your Shiny app.## How to install?
Pick the stable version from CRAN:
```r
install.packages("shiny.worker")
```or the latest from GitHub:
```r
remotes::install_github("Appsilon/shiny.worker")
```## Example
See live example [here](https://connect.appsilon.com/shiny-worker/) or more examples with code in the `examples/` folder.
### How to use it?
Initialise your worker at the beggining of your app.
```r
worker <- initialize_worker()
```Then, in the server of your Shiny app define a promise that returns a reactive when your heavy job will be completed.
```r
my_heavy_calculations <- function(args) {
# ...
args
}# this reactive object is used to trigger the job start,
# but also to pass parameters to the function
reactive_arguments <- reactive({
input$start
list(r = rnorm(1))
})# resultPromise will be a reactive value with results returned by my_heavy_calculations
resultPromise <- worker$run_job("job1", my_heavy_calculations, args_reactive = reactive_arguments)resultPromise()$result # contains the result of the calculations
resultPromise()$resolved # contains flag that informs whether the job has finished or not
```## Appsilon
Appsilon is a **Posit (formerly RStudio) Full Service Certified Partner**.
Learn more at [appsilon.com](https://appsilon.com).Get in touch [[email protected]](mailto:[email protected])
Explore the [Rhinoverse](https://rhinoverse.dev) - a family of R packages built around [Rhino](https://appsilon.github.io/rhino/)!