How to update a reactiveValues entry at startup

I want to set the value of a reactiveValues at startup of the application, but I get the following error:

Error : Can't access reactive value 'log_info' outside of reactive consumer.
:information_source: Do you need to wrap inside reactive() or observer()?

The problem is that I have nothing to observe or to reactive() to. It just starts up and I want to push some data into a reactiveValues at startup.

It's no problem to initialize a reactiveValues object at startup. To access a value you need a reactive context, unless you use isolate. See below and also the help of reactiveValues (?reactiveValues)


ui <- fluidPage(

server <- function(input, output) {
  values <- reactiveValues(a = 1)
  output$myvalue <- renderText({
    paste("My value is: ", values$a)
  cat(paste("My value is: ", isolate(values$a)))
shinyApp(ui, server)

I don't have any output$myvalue to pull the operation. I just want it to happen it regardless. In other environments it's called a lifetime event.

I only added the output$myvalue to show the initialized value. The initialization itself is done in the first line of the server

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.