Hi @Ajackson. debounce need a reactive expression as the argument. First, construct the reactive expression with reactive function on the input value that you want to target. The debounce function will output a reactive expression like the first argument that pass to it with addition of debounce property. Then, you can use the reactive expression for the following plotting.
library(shiny)
library(tidyverse)
shinyApp(
ui = basicPage(
titlePanel("Test of debounce"),
# Sidebar with selector for which species
sidebarLayout(
sidebarPanel(
checkboxGroupInput("species", label = "choose species",
choices = list("Setosa"="setosa",
"Versicolor"="versicolor",
"Virginica"="virginica"
),
selected = "")
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("plot1")
)
)
), # basicPage
#####################################################
# Define Server
#####################################################
server <- function(input, output, session) {
species <- reactive(input$species)
species_d <- species %>%
debounce(2000)
##################################
# Make Plot
##################################
draw_plot <- function() {
print(paste("species",species_d()))
output$plot1 <- renderPlot({
if (!is.null(species_d())){
iris %>%
filter(Species %in% species_d()) %>%
ggplot(aes(x=Petal.Length, y=Petal.Width)) +
geom_point(aes(color=Species))
}
})
}
##################################
# CheckBoxes
##################################
observeEvent(species_d(), {
draw_plot()
}, ignoreNULL=FALSE, ignoreInit=TRUE)
}
)