Skip to content

Commit

Permalink
Add example app for invalidateLater
Browse files Browse the repository at this point in the history
  • Loading branch information
jcheng5 committed Mar 12, 2014
1 parent 08bfa79 commit 6fe4f3b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
7 changes: 7 additions & 0 deletions invalidatelater/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Title: Current Time
Author: Joe Cheng <joe@rstudio.com>
AuthorUrl: http://www.rstudio.com/
License: MIT
DisplayMode: Showcase
Tags: invalidatelater
Type: Shiny
13 changes: 13 additions & 0 deletions invalidatelater/server.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
options(digits.secs = 3) # Include milliseconds in time display

shinyServer(function(input, output, session) {

output$currentTime <- renderText({
# invalidateLater causes this output to automatically
# become invalidated when input$interval milliseconds
# have elapsed
invalidateLater(as.integer(input$interval), session)

format(Sys.time())
})
})
13 changes: 13 additions & 0 deletions invalidatelater/ui.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
shinyUI(basicPage(
h4(
"The time is ",
# We give textOutput a span container to make it appear
# right in the h4, without starting a new line.
textOutput("currentTime", container = span)
),
selectInput("interval", "Update every:", c(
"5 seconds" = "5000",
"1 second" = "1000",
"0.5 second" = "500"
), selected = 1000, selectize = FALSE)
))

0 comments on commit 6fe4f3b

Please sign in to comment.