Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add outputOptions() to allow an output to render ASAP rather than wait for flush #1705

Open
daattali opened this issue May 11, 2017 · 4 comments

Comments

@daattali
Copy link
Contributor

daattali commented May 11, 2017

Consider this code

library(shiny)

ui <- fluidPage(
  actionButton("btn", "Click"),
  uiOutput("out")
)

server <- function(input, output) {
  values <- reactiveValues(foo = NULL)
  
  observeEvent(input$btn, {
    values$foo <- "bar"
     Sys.sleep(1)
  })
  
  output$out <- renderUI({
    values$foo
  })
}

shinyApp(ui = ui, server = server)

It'd be useful to be able to tell shiny to update the text output immediately when the reactive value is assigned instead of waiting for the flush.

@jcheng5
Copy link
Member

jcheng5 commented May 11, 2017

(Thanks!)

@geotheory
Copy link

I'd really like to see this feature added too.

If it's just text field I find this works (I have it wrapped inside an observeEvent):

withCallingHandlers({
  shinyjs::html("txt_field", "")
  message('foo')
},
message = function(m) { shinyjs::html(id = "txt_field", html = m$message, add = TRUE) }
)

@daattali
Copy link
Contributor Author

I read this somewhere in the async package docs:

No inputs are received from the browser until all pending async outputs/observers have completed.

It reminded me of this issue. This means that async will not be useful to someone who's performing an expensive calculation and wants to continue to be able to use the app. I think the ability of being able to tell shiny to let an output render whenever it's ready without blocking the others, coupled with the new async capability, is going to be very powerful.

@ismirsehregal
Copy link
Contributor

No inputs are received from the browser until all pending async outputs/observers have completed.

Just for the record: regarding async there is a non-blocking workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants