To answer your questions:
- In fact, any reactive expression is updated only after updating one of the reactive expressions that depend on it. Shiny does this to pass the invalidate flag whenever the value of the reactive expression changes to all other reactive expressions that depend on it. The next time these invalid reactive expressions are used, they are recounted. So in your case,
queriedData (which is a reactive expression) will be invalidated and therefore updated every time it gets the invalidate flag from input$a . Since the database query is part of this calculation, your assumption is correct. - It depends. When
input$a not changed and therefore queriedData not invalid, it simply returns the cached data. When input$a really changed, queriedData recalculated and therefore will generate a request. - Since only reactive expressions can pass the invalidate flag, these are the only ones that can cause another reactive expression to be recalculated. If the other parts do not respond, they cannot be invalidated either and therefore cannot cause the recalculation of
queriedData .
Keep in mind that a reactive expression does not have to be an input. Take the following example:
query <- reactive({paste0(...,input$a,...)}) queriedData <- reactive({ db$find(query()) }) output$thedata <- renderDataTable(queriedData())
Now changing input$a will invalidate the query , causing it to recount. query , a reactive expression, invalidates queriedData() , causing it to be queriedData() . This will invalidate output$thedata and therefore will cause this part to be recounted, which will result in new data specified in the data table.
source share