hafen / trelliscopejs

TrelliscopeJS R Package
https://hafen.github.io/trelliscopejs
Other
262 stars 36 forks source link

`is_in_shiny()` returning `NULL` #115

Closed kaneplusplus closed 2 years ago

kaneplusplus commented 2 years ago

I'm running into an issue where is_in_shiny() can return NULL. Can I suggest the following change to the function?

is_in_shiny <- function() {
  res <- FALSE
  tmp <- try(utils::getFromNamespace(".globals", "shiny")$appState,
    silent = TRUE)
  if (!inherits(tmp, "try-error") && !is.null(tmp))
    res <- TRUE
  if (is.null(res))
    res <- FALSE
  res
}