@NielsKrarup. What the purpose of your code to use reactiveValues? If you want to automatically trigger each plot, you can delay the update of reactiveValues and let it have time to update the plots.
library (shiny)
library (shinyjs)
if (interactive()) {
ui <- fluidPage(
useShinyjs(),
plotOutput("plot1"),
plotOutput("plot2")
)
# The comments below show the equivalent logic using reactiveValues()
server <- function(input, output, session) {
Reactive_values <- reactiveValues() # rv <- reactiveValues(value = 0)
output$plot1 <- renderPlot({
xmax2 <- Reactive_values$xmax2
isolate({
x <- rnorm(100)
delay(500, {Reactive_values$xmax1 <- max(x)})
xmax <- max(c(Reactive_values$xmax1, xmax2))
y <- sin(x^2)
plot(x,y, main = paste0(round(max(x),3)), xlim = c(-3, xmax) )
})
})
output$plot2 <- renderPlot({
xmax1 <- Reactive_values$xmax1
isolate({
x <- rnorm(100, mean = 1)
delay(500, {Reactive_values$xmax2 <- max(x)})
xmax <- max(c(xmax1, Reactive_values$xmax2))
y <- sin(x^2)
plot(x,y, main = paste0(round(max(x),3)), xlim = c(-3, xmax))
})
})
}
shinyApp(ui, server)
}