I'm trying to use Shiny.onInputChange()
in javascript to send a message to R when the shiny:busy
event gets fired. This causes a never-ending cycle of messages. I'm wondering if anyone can think of a clean way to avoid this infinite recursion, without doing something hacky like creating a boolean flag that gets set to true/false to indicate we should stop.
Sample code:
# Using this to see the messages being sent to shiny
options(shiny.trace=TRUE)
library(shiny)
ui <- fluidPage(
tags$script("
$(function() {
$(document).on('shiny:busy', function(event) {
Shiny.setInputValue('test', 'test', {priority: 'event'});
});
});"
)
)
server <- function(input, output, session) {
observeEvent(input$test, cat('test'))
}
shinyApp(ui, server)
Conceptually I'm not sure this is possible because shiny is busy when sending a message, but perhaps there's a trick I haven't thought of to tell shiny not to consider itself busy or at least ignore that message. Maybe there's some way to tell what triggered the "busy"ness