You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have no success getting code within an extended task (i.e. shiny::ExtendedTask()) to become available via shinymeta. I imagine a metaExtendedTask() is missing to make this happen but, perhaps, I am over-complicating the problem.
Is there a simple workaround that I am not aware of?
If not, is this on anyone's feature list?
The code below is based on the ExtendedTask documentation with the output made meta-enabled. I think metaAction wrapped around the relevant code ( see "# Slow operation goes here" ) is the way forward, but not the complete answer.
library(shiny)
library(shinymeta)
ui <- page_fluid(
titlePanel("Extended Task Demo"),
p(
'Click the button below to perform a "calculation"',
"that takes a while to perform."
),
input_task_button("recalculate", "Recalculate"),
p(textOutput("result"))
)
server <- function(input, output) {
rand_task <- ExtendedTask$new(function() {
future(
{
# Slow operation goes here
Sys.sleep(2)
sample(1:100, 1)
},
seed = TRUE
)
})
# Make button state reflect task.
# If using R >=4.1, you can do this instead:
# rand_task <- ExtendedTask$new(...) |> bind_task_button("recalculate")
bind_task_button(rand_task, "recalculate")
observeEvent(input$recalculate, {
# Invoke the extended in an observer
rand_task$invoke()
})
output$result <- shinymeta:metaRender(
shiny::renderText,
{
# React to updated results when the task completes
number <- rand_task$result()
paste0("Your number is ", number, ".")
})
}
shinyApp(ui, server)
The text was updated successfully, but these errors were encountered:
I have no success getting code within an extended task (i.e.
shiny::ExtendedTask()
) to become available via shinymeta. I imagine ametaExtendedTask()
is missing to make this happen but, perhaps, I am over-complicating the problem.Is there a simple workaround that I am not aware of?
If not, is this on anyone's feature list?
The code below is based on the
ExtendedTask
documentation with the output made meta-enabled. I thinkmetaAction
wrapped around the relevant code ( see "# Slow operation goes here" ) is the way forward, but not the complete answer.The text was updated successfully, but these errors were encountered: