Skip to content

❗ This is a read-only mirror of the CRAN R package repository. shiny.worker — Delegate Jobs for Shiny Web Applications

License

Notifications You must be signed in to change notification settings

cran/shiny.worker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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?

remotes::install_github("Appsilon/shiny.worker")

Example

See live example here.

How to use it?

Initialise your worker at the beggining of your app.

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.

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

See more examples in the examples/ folder.

Appsilon

Appsilon is the Full Service Certified RStudio Partner. Learn more at: appsilon.com or get in touch: dev@appsilon.com.

About

❗ This is a read-only mirror of the CRAN R package repository. shiny.worker — Delegate Jobs for Shiny Web Applications

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages