Created
October 30, 2020 18:42
-
-
Save awwsmm/40591481d158ea0ff361b6bcaeca04df to your computer and use it in GitHub Desktop.
Minimal Idle / Incremental Clicking "Game" in R 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
library(shiny) | |
ui <- basicPage( | |
actionButton("theButton", "gotta click"), | |
verbatimTextOutput("theNumber") | |
) | |
server <- function(input, output, session) { | |
vals <- reactiveValues(counter = 0) | |
# add 1 to number every second | |
observe({ | |
invalidateLater(1000 / (input$theButton + 1), session) | |
vals$counter <- isolate(vals$counter) + 1 | |
output$theNumber <- renderText({ vals$counter }) | |
}) | |
} | |
# Run the application | |
shinyApp(ui = ui, server = server) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment