With
options(shiny.trace = TRUE)
we see lots of messages (example below). At https://shiny.rstudio.com/articles/debugging.html
we learn
SEND indicates data sent from the browser to the R session.
RECV indicates data sent from the R session to the browser.
This seems backwards to me.
For example, for the Fibonacci example at
when setting the value of n to 9, the I see this:
RECV {"method":"update","data":{"n:shiny.number":9}}
SEND {"progress":{"type":"binding","message":{"id":"nthValue"}}}
SEND {"busy":"busy"}
SEND {"recalculating":{"name":"nthValue","status":"recalculating"}}
SEND {"recalculating":{"name":"nthValue","status":"recalculated"}}
SEND {"busy":"idle"}
SEND {"errors":,"values":{"nthValue":"fib = 34"},"inputMessages":}
It seems pretty clear that RECV is showing the web browser sending the value 9 to R,
then R is busy recalculating the nthValue (fibonacci number),
finally R is sending the value 34 back to the browser for display in the outputText("nthValue") div,
which is
<div id="nthValue" class="shiny-text-output"></div>
.
So, the descriptions of SEND and RECV are reversed, is that right?
If not, can you help me interpret these trace messages correctly?
Here is the complete app:
fib <- function(n) ifelse(n<3, 1, fib(n-1)+fib(n-2))
server <- function(input, output) {
currentFib <- reactive({ fib(as.numeric(input$n)) })
output$nthValue <- renderText({ paste('fib = ', currentFib()) })
}
ui <- div("FIB", numericInput('n', 'n', 5),
textOutput('nthValue'))
shinyApp(ui=ui, server=server)