R/to_reactive.R

Defines functions to_reactive

Documented in to_reactive

#' Check and convert a value into a reactive function
#'
#'
#' @description For some use cases in shiny app development, you will need to check if a value is a
#' reactive function or reactive value.  To preserve the generalizeable functionality of the ui and server functions,
#' this supporting function is used to convert a static value or values into a reactive declaration to be
#' used later on in the function.
#'
#' @param x object to convert if NOT already a reactive function
#'
#' @return Reactive function
#'
#' @importFrom shiny is.reactive
#' @importFrom shiny reactive
#'

to_reactive<-function(x){
  if(!is.reactive(x)) return(reactive(x))
  return(x)
}
HarryRosen/hrimodules documentation built on Jan. 11, 2022, 12:36 a.m.