forked from daattali/advanced-shiny
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.R
35 lines (30 loc) · 876 Bytes
/
app.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
library(shiny)
library(shinyjs)
source("helpers.R") # Load all the code needed to show feedback on a button click
ui <- fluidPage(
useShinyjs(),
tags$style(appCSS),
selectInput("select", "Select an option",
c("This one is okay" = "ok",
"This will give an error" = "error")),
# Wrap the button in the function `withBusyIndicatorUI()`
withBusyIndicatorUI(
actionButton(
"uploadFilesBtn",
"Process data",
class = "btn-primary"
)
)
)
server <- function(input, output, session) {
observeEvent(input$uploadFilesBtn, {
# When the button is clicked, wrap the code in a call to `withBusyIndicatorServer()`
withBusyIndicatorServer("uploadFilesBtn", {
Sys.sleep(1)
if (input$select == "error") {
stop("choose another option")
}
})
})
}
shinyApp(ui = ui, server = server)