Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/Appsilon/shiny.worker

Intra-session reactivity in Shiny
https://github.com/Appsilon/shiny.worker

r rhinoverse shiny

Last synced: about 2 months ago
JSON representation

Intra-session reactivity in Shiny

Awesome Lists containing this project

README

        

# shiny.worker shiny.worker logo

> _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/)!

We are hiring!