2017-08-22 102 views
0

进出口新的闪亮[R ...这里是我的代码...如何停止暂停执行在observeEvent()闪亮[R

ui.R

library(shiny) 
fluidPage(mainPanel(actionButton("run","RUN"))) 

server.R

function(input, output) { 
    observeEvent(input$run,{ 
       print("Start") 
       Sys.sleep(2) 
       print("End")}) 
} 

问题是...当我按控制台之前打印前打印“结束”....它开始继续执行observeEvent尽快之前observeEvent结束......有没有什么办法可以停止管道的observeEvent队列? ??

我要的就是阻止用户交互上的“运行”按钮,功能已经在执行...

回答

0

有点搜索后,我终于得到了解决....这解决了我的目的... 。

ui.R

library(shiny) 
library(shinyjs) 
fluidPage(shinyjs::useShinyjs(),mainPanel(actionButton("run","RUN"))) 

server.R

function(input, output) { 
    observeEvent(input$run,{ 
    shinyjs::disable("run") 
       print("Start") 
       Sys.sleep(2) 
       print("End") 
       shinyjs::enable("run")}) 
}