Priority value in reactive (), as in observation mode () (R Shiny)

How do you set the priority at which calculations are performed reactive()in Shiny? For example, there is an option priorityin observe()quoting the help file

priority
    An integer or numeric that controls the priority with which this observer 
should be executed. An observer with a given priority level will always execute
sooner than all observers with a lower priority level. Positive, negative, 
and zero values are allowed.

I want to apply this if my Shiny toolbar displays some summary statistics before writing these statistics to the logging database, here is an example

To server.Rretrieve data every hour

observe({
    invalidateLater(3600000,session)
    con <- dbConnect(PostgreSQL(), ...)

    values$data = dbGetQuery(con, "select * from table;")
})

output$text = renderText({
    temp = values$data
    print(paste("the mean is", mean(temp)))
})

observe({
    temp = values$data
    dbWriteTable(con, paste0("Insert into table_means Values (", (mean(temp),");" ))
})

And in ui.RI print the average of the data.

I want UI rendering to happen before writing values ​​to my sql database

Here are some related questions :

R shiny , Null

+4
1

, : R , selectInput

** outputOptions, ( ):

## Not run:
# Get the list of options for all observers within output
outputOptions(output)

# Disable suspend for output$myplot
outputOptions(output, "myplot", suspendWhenHidden = FALSE)

# Change priority for output$myplot
outputOptions(output, "myplot", priority = 10)

# Get the list of options for output$myplot
outputOptions(output, "myplot")
## End(Not run)

, , , observe().

0

Source: https://habr.com/ru/post/1543027/


All Articles