Parallel timer

9 views
Skip to first unread message

Alex Champion

unread,
Jun 21, 2017, 7:25:29 AM6/21/17
to Shiny - Web Framework for R
Hello guys,
I'm new here so thanks in advance for helping me. I have one question about parallel programming.
I`m developing a Shiny app and I need to show a timer which increments its value in one each second.
Moreover I have also several pieces of code which are executed when action buttons are pressed.

I have done several tests and each time I click an action button (and a piece of code is executed), the timer stops.
I know open source R is single thread, I think the problem is related to this fact.

Is there any way to combine a timer without being stopped by the program execution??

Regards,

Joe Cheng

unread,
Jun 22, 2017, 4:50:09 PM6/22/17
to Alex Champion, Shiny - Web Framework for R
Can you show your test code?

--
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/69148be1-4b0e-46ec-8d1f-07d9943e3ad0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alex Champion

unread,
Jun 26, 2017, 7:41:53 AM6/26/17
to Shiny - Web Framework for R, alex...@gmail.com
With tests I meant I was changing code several times. The piece of code is the following:

In ui:

fluidRow(column(6,uiOutput('timer')))

In server :

server <- function(input,output,session){
    
    update_time <- reactive({
      invalidateLater(1000)
      trunc(Sys.time() - time)
    })
    
    output$timer <- renderText({
      paste('Execution time :',update_time(),' seconds',sep='')
    })

I set time as a global variable at the beginning of the app.
The code runs perfect until I press whatever action button I have in the app.
How can I handle this issue?

Thanks in advance.
Reply all
Reply to author
Forward
0 new messages