【问题标题】:how to control the update propagation order in shiny如何控制闪亮的更新传播顺序
【发布时间】:2017-07-08 16:15:27
【问题描述】:

您好,我想在一些计算后从服务器端发送一个“假”输入更新。换句话说,我想控制输出更新传播的顺序。

例如,在下面的脚本中,我需要在第二个 observeEvent 的 Sys.sleep 之后更新 output$text :

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)

非常感谢

【问题讨论】:

    标签: r shiny shinyjs


    【解决方案1】:

    正如我在评论中提到的:在?oberserveEvent 中,您可以设置参数priority。优先级较高的函数将首先被评估。

    【讨论】:

      猜你喜欢
      • 2015-10-02
      • 2019-01-10
      • 2018-03-03
      • 2023-03-29
      • 2013-06-25
      • 1970-01-01
      • 2022-07-19
      • 2020-01-08
      • 1970-01-01
      相关资源
      最近更新 更多