How to make a shiny app survive...

92 views
Skip to first unread message

Lukasz Kiljanek

unread,
Jun 16, 2016, 4:24:58 AM6/16/16
to Shiny - Web Framework for R
Once my apps shows results, users can review for minutes ...

I don't want the app to die (reload - disconnected message ) when user is still scrolling website on mobile( with finger) and with mouse, mouse wheel... Etc?

There has to be an easy JS way?

I am a newbie to JS.

Anyone please?
Best
Luke

Aaron Hoffer

unread,
Jun 21, 2016, 1:49:25 AM6/21/16
to Shiny - Web Framework for R
The shinyJS package allows you to track events using onEvent(). There is a jquery.mousewheel plugin that allows you to track "mousewheel" events. Here's a minimum example to implement. This won't work for mobile, but you may be able to use touchmove or scroll for that.

library(shiny)
library(shinyjs)

shinyApp(
  ui = fluidPage(
    useShinyjs(),
    div(id = "foo", style = "height:800px;",
        textOutput("val_a"))
  ),
  server = function(input, output) {
    a <<- 1
    shinyjs::onevent("mousewheel", "foo", myFunc())
    myFunc = function() {
      output$val_a = renderText({a <<- a + 1; a})
    }
  }
)

Joe Cheng

unread,
Jun 21, 2016, 2:12:21 AM6/21/16
to Aaron Hoffer, Shiny - Web Framework for R
The disconnection after idling is a feature that you can control through the ShinyApps.io dashboard. Log into shinyapps.io, click the app name, and go to Settings | Advanced | Connection Timeout. You can set this to a very large number if you want.

--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/fd2cb604-17e5-4ca3-a798-c773f443d95b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages