Debian Codegraph @

R/globals.R

raw
1 # A scope where we can put mutable global state
2 .globals <- new.env(parent = emptyenv())
3
4 .onLoad <- function(libname, pkgname) {
5 # R's lazy-loading package scheme causes the private seed to be cached in the
6 # package itself, making our PRNG completely deterministic. This line resets
7 # the private seed during load.
8 withPrivateSeed(set.seed(NULL))
9
10 for (expr in on_load_exprs) {
11 eval(expr, envir = environment(.onLoad))
12 }
13
14 # Make sure these methods are available to knitr if shiny is loaded but not
15 # attached.
16 s3_register("knitr::knit_print", "reactive")
17 s3_register("knitr::knit_print", "shiny.appobj")
18 s3_register("knitr::knit_print", "shiny.render.function")
19 }
20
21
22 on_load_exprs <- list()
23 # Register an expression to be evaluated when the package is loaded (in the
24 # .onLoad function).
25 on_load <- function(expr) {
26 on_load_exprs[[length(on_load_exprs) + 1]] <<- substitute(expr)
27 }
28
29 on_load({
30 IS_SHINY_LOCAL_PKG <- exists(".__DEVTOOLS__")
31 })