-
-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redundant reactivity cycle on initialization - insertUI #443
Comments
DRAFT: The main problem are splash UI/SRV which are taken from data argument. Another problem is that each module ui is feed with a reactive datasets, and before for teal.transform::resolve_delayed. Options:
|
New example: All inputs should be available from the first line of code in the shiny app server. When we use The example app will print Notice: commented library(shiny)
ui <- fluidPage(
titlePanel("Old Faithful Geyser Data"),
sidebarLayout(
sidebarPanel(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30),
div(id = "input_example")
),
mainPanel(
plotOutput("distPlot")
)
)
)
server <- function(input, output, session) {
session$onFlush( function() message("Start flush"), once = FALSE)
session$onFlushed( function() message("End flush"), once = FALSE)
# immediate inset
insertUI("#input_example", immediate = TRUE, ui = textInput(session$ns("sth"), "sth", "sth"))
output$distPlot <- renderPlot({
# input$sth is not visible in the first cycle.
# req(input$sth) will solve it
# browser()
print(paste("input$bins:", deparse1(input$bins)))
print(paste("input$sth:", deparse1(input$sth)))
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = input$bins + 1)
hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
}
shinyApp(ui = ui, server = server)
# Listening on http://127.0.0.1:7193
# [1] "input$bins: 30L"
# [1] "input$sth: NULL"
# Start flush
# End flush
# [1] "input$bins: 30L"
# [1] "input$sth: \"sth\""
# Start flush
# End flush |
find out here insightsengineering/teal.modules.general#277 (review)
Objective:
Solve the problem of a redundant reactivity cycle. Most probably the insertUI have to be removed, and replace by other solution. If could not be solved then we need a
proper Agile-R (or vignette) subsection, where it is communicatedroxygen with explanation.Summary:
When we use insertUI with immediate option, the UI is visible immediately. However inputs inserted (by insertUI) are not yet added to the client. So we have to wait for the next reactive round. Thus the first reactive round return NULL for all module inputs.
This is a global NEST thing as it comes from the teal::srv_teal function.
Code:
teal/R/module_teal.R
Line 205 in 27d35cf
Example why insertUI adding redundant reactivity cycle.
Warning:
browser
in both apps.inputs should be available from the first line of code in server, like here (example shiny app):
However when we use insertUI (even with immediate option) with shiny inputs then we have to wait for second reactive cycle to see inputs added by insertUI.
The text was updated successfully, but these errors were encountered: