I'm trying to update a uiOutput using the change in reactiveValues
from inside a loop, but it doesn't seem to work.
I've looked into some answers, but they're all trying to work it from inside output$somthing, which is not the case here:
like those:
Update shiny output within loop
For loop inside output in Shiny
Here some reproducible app.
vars = reactiveValues(cc="",ct=0)
ui = fluidRow(uiOutput("warngt"),actionButton("searchgt","Search"))
server = function(input, output, session){
observeEvent(input$searchgt,{
if(vars$ct<10){
repeat{
vars$ct=vars$ct+1
vars$cc=paste(sprintf('<b style="color:blue">',"Searching...[%s]",vars$ct),"</b>");Sys.sleep(.5)
#This also does not work:
#output$warngt=renderUI({HTML(vars$cc)})
vars$busca = try(print("Something"),silent = T)
if(vars$ct==10){break}
}
}else{
#This work just fine
vars$cc=paste('<b style="color:red">',"Some warning.","</b>")
}
#This also doesn't work
#output$warngt=renderUI({HTML(vars$cc)})
})
output$warngt = renderUI({HTML(vars$cc)})
}
shinyApp(ui = ui, server = server)
Thanks in advance!