every: Evaluate an Expression on a Fixed Time Interval

Description Usage Arguments Value See Also Examples

View source: R/every.R

Description

Can be used as a keepalive utility for external connections such as SSH and WebSocket, or Shiny itself; Can also be used as a watchdog to periodically check on something. This functions is thin wrapper around shiny::reactiveTimer() and shiny::observe().

Usage

1
every(seconds = 1, do = cat("Thump!"), ...)

Arguments

seconds

time interval in seconds

do

expression

...

any other arguments passed to shiny::observe()

Value

Shiny observer

See Also

[shiny::observe()]

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
## Not run: 
every(60, {
  cat("Keeping Connection Alive...\n")
  ssh::ssh_exec_internal(session = my_session,
                         command = "whoami")
})

shinyApp(
fluidPage(
   shinyjs::useShinyjs(),
   actionButton("stop", "Stop"),
   textInput("blinker", "Blinker Input"),
),
function(input, output, session) {
   heartbeat <- shinybeats::every(1.2, {
       shinyjs::toggle("blinker")
   })

   observeEvent(input$stop,{
       heartbeat$destroy()
   })
}
)

## End(Not run)

iqis/shinybeats documentation built on May 14, 2020, 12:33 a.m.