eventReactive not executed from actionButton on other tab

I'm developing an app that gathers input from 10 elements (sliders, fields, dropdowns) grouped in one tab of a navbarPage, then runs some code and outputs a dozen graphs, tables and text. Since there is much output, I want to display it in several other tabs. Since execution can take a minute I start it with an actionButton.

The problem is that it appears the code that is governed by eventReactive is only executed when a tab is clicked. The result is that I click the actionButton and it turns grey, which is an indication that the code has been started. However only when I click each tab is the code executed and the resulting graphs shown in the other tabs. That leads to strange behaviour for the user: click the Run button, nothing happens, click a tab and wait for some time until the code runs and produces output.

Here is the least amount of code I can show to demonstrate. It's based on one of the examples on the Shiny website, with tabs added and a sleep before the graph production so that it becomes apparent that the code is only executed when the tab is clicked. Without the sleep, the code runs so fast that you cannot tell its not already there when the content of the tab becomes visible.

This also happens with the tabsetPanel control. And it happens when the button is moved outside the tabsetPanel/navbarPage control.

Help is greatly appreciated.

library(shiny)

ui <- fluidPage(
navbarPage("Demo",
tabPanel("Inputs",
),
tabPanel("Output",
numericInput("n", "n", 50),
plotOutput("plot")
)
),
actionButton("go", "Go")
)

server <- function(input, output) {

randomVals <- eventReactive(input$go, {
Sys.sleep(3)
runif(input$n)
})

output$plot <- renderPlot({
hist(randomVals())
})
}

shinyApp(ui, server)

libraary(shiny)

ui <- fluidPage(
  navbarPage("Demo",
             tabPanel("Inputs",
             ),
             tabPanel("Output",
                      numericInput("n", "n", 50),
                      plotOutput("plot")
             )
  ),
  actionButton("go", "Go")
)

server <- function(input, output) {
  
  randomVals <- reactiveVal(NULL)
  
  observeEvent(input$go, {
    cat("go pressed\n")
    Sys.sleep(3)
    cat("go finished\n")
    randomVals(runif(input$n))
  })
  
  output$plot <- renderPlot({
    hist(randomVals())
  })
}

shinyApp(ui, server)

That solves my problem. Many thanks for the competent reply!