R 如何控制系统中的更新传播顺序
嗨,我想发送一个“假”输入更新从服务器端经过一些计算。换句话说,我想控制输出更新传播的顺序 例如,在下面的脚本中,我需要在第二个observeEvent中的Sys.sleep之后更新输出$text:R 如何控制系统中的更新传播顺序,r,shiny,shinyjs,R,Shiny,Shinyjs,嗨,我想发送一个“假”输入更新从服务器端经过一些计算。换句话说,我想控制输出更新传播的顺序 例如,在下面的脚本中,我需要在第二个observeEvent中的Sys.sleep之后更新输出$text: library(shiny) ui <- fluidPage( titlePanel("PLOP"), sidebarLayout( sidebarPanel( selectInput("variable", "Variable:",
library(shiny)
ui <- fluidPage(
titlePanel("PLOP"),
sidebarLayout(
sidebarPanel(
selectInput("variable", "Variable:",
c("Cylinders" = "cyl",
"Transmission" = "am",
"Gears" = "gear")),
actionButton("press","press")
),
mainPanel(
textOutput("text")
)
)
)
server <- function(input, output) {
output$text <- renderText({
input$press
message("rendertext at ",Sys.time())
paste(input$variable,Sys.time())})
observeEvent(input$variable,
message("variable is edited at ",Sys.time())
)
observeEvent(input$press,{
message("button is presed at ",Sys.time())
# lot of stuff
Sys.sleep(2)
message("end calculation at ",Sys.time())
# AND NOW I would like to send a "false" input$variable update
# I dont want to change input$variable, but I need to rerun everything which use input$variable
# ( .... ) for example : changing output$text but AFTER the Sys.sleep call
})
}
# Run the application
shinyApp(ui = ui, server = server)
库(闪亮)
ui正如我在评论中提到的:在?oberserveEvent
中,您可以设置参数优先级
。优先级较高的函数将首先进行评估