Skip to content

Commit

Permalink
Some assign parts fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mattfidler committed Jul 30, 2024
1 parent d8c2d2a commit ed6b004
Showing 2 changed files with 18 additions and 4 deletions.
3 changes: 1 addition & 2 deletions R/ui-assign-parts.R
Original file line number Diff line number Diff line change
@@ -293,8 +293,7 @@

#' @export
`$<-.rxUi` <- function(x, name, value) {
.raw <- inherits(x, "raw")
if (!.raw) {
if (is.environment(x)) {
assign(name, value, envir=x)
return(x)
}
19 changes: 17 additions & 2 deletions R/ui.R
Original file line number Diff line number Diff line change
@@ -436,7 +436,21 @@ print.rxUi <-function(x, ...) {
#'
rxUiDecompress <- function(ui) {
if (!inherits(ui, "rxUi")) return(ui)
if (is.environment(ui)) return(ui)
if (is.environment(ui)) {
if (!exists("meta", envir=ui)) {
.m <- list()
} else {
.m <- get("meta", envir=ui)
}
if (is.list(.m)) {
.meta <- new.env(parent=emptyenv())
lapply(names(.m), function(x) {
assign(x, .m[[x]], .meta)
})
assign("meta", .meta, ui)
}
return(ui)
}
if (is.raw(ui)) {
.ret <- try(qs::qdeserialize(ui), silent=TRUE)
if (inherits(.ret, "try-error")) {
@@ -455,8 +469,9 @@ rxUiDecompress <- function(ui) {
lapply(names(ui), function(x) {
if (x == "meta") {
assign(x, .meta, .ret)
} else {
assign(x, ui[[x]], .ret)
}
assign(x, ui[[x]], .ret)
})
class(.ret) <- "rxUi"
return(.ret)

0 comments on commit ed6b004

Please sign in to comment.