Debian Codegraph @

R/app-state.R

raw
1 #' @include globals.R
2 NULL
3
4 # The current app state is a place to read and hang state for the
5 # currently-running application. This is useful for setting options that will
6 # last as long as the application is running.
7
8 .globals$appState <- NULL
9
10 initCurrentAppState <- function(appobj) {
11 if (!is.null(.globals$appState)) {
12 stop("Can't initialize current app state when another is currently active.")
13 }
14 .globals$appState <- new.env(parent = emptyenv())
15 .globals$appState$app <- appobj
16 # Copy over global options
17 .globals$appState$options <- .globals$options
18 }
19
20 getCurrentAppState <- function() {
21 .globals$appState
22 }
23
24 clearCurrentAppState <- function() {
25 .globals$appState <- NULL
26 }