From 276af32d6463fdd397e37c5806447dd2005e34da Mon Sep 17 00:00:00 2001 From: amy17519 Date: Mon, 30 Nov 2020 16:56:45 -0800 Subject: [PATCH] remove global assignment --- NAMESPACE | 1 + R/ggthemr_current.R | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 75ec767..85c16cd 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -73,4 +73,5 @@ importFrom(grDevices,colors) importFrom(grDevices,rgb) importFrom(graphics,layout) importFrom(scales,seq_gradient_pal) +importFrom(utils,assignInMyNamespace) importFrom(utils,head) diff --git a/R/ggthemr_current.R b/R/ggthemr_current.R index 3e5c4d5..b1a492d 100644 --- a/R/ggthemr_current.R +++ b/R/ggthemr_current.R @@ -1,7 +1,9 @@ +themr <- NULL + #' @title Store Theme #' @description Store ggthemr theme. +#' @importFrom utils assignInMyNamespace ggthemr_current <- (function () { - themr <- NULL list( get = function () { if (is.null(themr)) { @@ -12,13 +14,15 @@ ggthemr_current <- (function () { }, set = function (value) { verify_ggthemr(value) - themr <<- value + assignInMyNamespace('themr', value) + # themr <<- value }, is_set = function () { !is.null(themr) }, clear = function () { - themr <<- NULL + assignInMyNamespace('themr', NULL) + # themr <<- NULL } ) })()