I am using shiny in R and want to render more than once when using observeEvent in server.R
I don't understand why this does not work:
library(shiny)
my_UI <- fluidPage(
fluidRow(actionButton("test", "test")),
fluidRow(textOutput("out"))
)
my_Server <- function(input, output) {
observeEvent(input$test, {
output$out <- renderText("waiting")
Sys.sleep(2)
output$out <- renderText("done")
})
}
shinyApp(my_UI, my_Server)
I also tried:
library(shiny)
my_UI <- fluidPage(
fluidRow(actionButton("test", "test")),
fluidRow(textOutput("out"))
)
my_Server <- function(input, output) {
observeEvent(input$test, {
output$out <- renderText("waiting")
})
observeEvent(input$test, {
Sys.sleep(2)
output$out <- renderText("done")
})
}
shinyApp(my_UI, my_Server)
In both cases, only the latter message is rendered... What am I doing wrong here? Thanks!