-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
)) |