I am using a future promise to call my data more efficiently. However, I'm finding that my filters (called through selecticizeGroupServer) do not work with the future promise.
See attached for a minimal reproducible example. The filters work as expected when I remove the "future_promise" function from the data reactive expression. However, when I use "future_promise," the filter module fails.
Could you please help me figure out what I'm doing wrong?
library(shiny)
library(future)
library(promises)
library(shinyWidgets)
plan(multisession)
ui <- fluidPage(
titlePanel("Example App"),
sidebarLayout(
sidebarPanel(),
mainPanel(
selectizeGroupUI(
id = "filters",
inline = FALSE,
params = list(
`mpg` = list(inputId = "mpg", title = "mpg", placeholder = "All"),
`cyl` = list(inputId = "cyl", title = "cyl", placeholder = "All"),
`disp` = list(inputId = "disp", title = "disp", placeholder = "All")
)
)
)
)
)
server <- function(input, output) {
data <- reactive({
future_promise({
mtcars
})
})
filter_mod <- reactive({})
observe({
filter_mod <<- callModule(
module = selectizeGroupServer,
id = "filters",
inline = FALSE,
data = data,
vars = c("mpg", "cyl", "disp")
)
})
}
# Run the application
shinyApp(ui = ui, server = server)
We can use a initialized
reactiveVal
instead ofreactive
to avoid passing a promise toselectizeGroupServer
.Please check the following: