Skip to content

Instantly share code, notes, and snippets.

@awwsmm
Created October 30, 2020 18:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save awwsmm/40591481d158ea0ff361b6bcaeca04df to your computer and use it in GitHub Desktop.
Save awwsmm/40591481d158ea0ff361b6bcaeca04df to your computer and use it in GitHub Desktop.
Minimal Idle / Incremental Clicking "Game" in R Shiny
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