Skip to content
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

getCurrentOutputInfo() should be more cache aware #3208

Open
cpsievert opened this issue Dec 15, 2020 · 1 comment
Open

getCurrentOutputInfo() should be more cache aware #3208

cpsievert opened this issue Dec 15, 2020 · 1 comment
Milestone

Comments

@cpsievert
Copy link
Collaborator

(Continuation of #3198 (comment))

Currently bindCache() doesn't consider getCurrentOutputInfo() when computing cache keys, but it probably should (especially considering that thematic implicitly calls it at plot time). For a minimal example of the suprising behavior it can lead to, run this app once to warm the cache), then change fg = "white" to fg = "red" notice how the fg of the plot remains unchanged (it should be red not white)

library(shiny)

shinyOptions(cache = cachem::cache_disk("./myapp-cache"))

ui <- fluidPage(
  theme = bslib::bs_theme(bg = "black", fg = "white"),
  "True foreground color",
  plotOutput("p")
)

server <- function(input, output, session) {
  output$p <- renderPlot(plot(1:10)) %>%
    bindCache()
}
thematic::thematic_shiny()
shinyApp(ui, server)
@cpsievert
Copy link
Collaborator Author

As a workaround, pass session$clientData$output_* to bindCache(), for instance:

output$p <- renderPlot(plot(1:10)) %>%
    bindCache(session$clientData$output_p_bg, session$clientData$output_p_fg)

Ideally bindCache() would do this automatically tho

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant