Experiemental work on forked computation in shiny app using the package "parallel".
Does not work on windows.
Rscript run.R
library(shiny)
source("helper.R")
# Define an expensive function
expensiveFunction <- function(){
for(i in 1:3){
Sys.sleep(1)
}
return(1:10)
}
# define a feedback function. res$data is the result, res$message is a process message.
feedbackFunction <- function(res){
output$plotExpensive <- renderPlot( barplot(res$data) )
}
# Do it in a forked process. Resulting 'pid' object is the process id. Can be used with tools::pskill to stop process.
pid <- do(
expr = expensiveFunction() ,
feedback = feedbackFunction()
)