fpsWhen: Conditionally file a signal at fixed fps.

Description Usage Arguments Value Examples

View source: R/time.R

Description

Conditionally file a signal at fixed fps.

Usage

1
fpsWhen(when, rate)

Arguments

when

A reactive that evaluates to TRUE or FALSE.

rate

Number of signals to fire per second

Value

A reactive giving the time in seconds since the last signal. The first time after a pause is always zero - this way summing the signal gives the amount of sum the output signal has been running

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
shinyApp(
  ui = fluidPage(
    textOutput("delta"),
    textOutput("running"),
    textOutput("count"),
    checkboxInput("pause", "pause")
  ),
  server = function(input, output) {
    tick <- reactive(!input$pause) %>% fpsWhen(10)
    running <- tick %>% reducePast(`+`, 0)
    count <- tick %>% count()
    output$delta <- renderText(tick())
    output$running <- renderText(running())
    output$count <- renderText(count())
  }
)

hadley/shinySignals documentation built on May 17, 2019, 12:47 p.m.