In my Shiny app users can generate heavy powerpoint report. When it contains a lot of slides it could take > 30 minutes to be done. And therefore I'd like to process those tasks in independent processes/tasks which could work even when app is closed - e.g. user clicks button to generate report, closes app and when report is ready app informs user by email. Are there any good practices or proven solutions to do this?
My first thought was using future
package with plan(multisession)
set - but I'm not sure what happens when user closes the app - future
session closes too or not?
I was lucky enough to be at London EARL this week and I think one of the best presentations I saw there was about exactly this (by Joe Cheng). You would need the promises package for this to work and as it says on the documentation a special version of shiny
devtools::install_github("rstudio/shiny@async")
that supports asynchronous programming.You can find a first documentation here on how this works by using
dplyr
andpromises
(future
is also compatible).As a small example (taken from the documentation), running an intensive calculation using the following:
would essentially return the console cursor back, allowing you to run any other command you want and would automatically open the
View
tab once this was finished. I might be able to dig out a shiny example in a bit, but keep in mind this is still under development and will be released before the end of the year (with a more comprehensive documentation I would imagine).