You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I ran into a very weird and subtle behavior involving modify_tree() on a list which includes
shiny::reactive()s
around some S3 class
take any of them away (unclass() the S3 class) or don't use a reactive, and the problem goes away.
Here's the reprex:
shiny::testServer(
app=function(input, output, session) {
# fails with this objectobj<- reactive(htmltools::HTML("foo"))
# works without a reactive# obj <- htmltools::HTML("foo")# works with class removed# obj <- reactive(unclass(htmltools::HTML("foo")))purrr::modify_tree(
x=obj,
is_node=function(x) is.reactive(x) || is.list(x),
pre=function(x) {
if (is.reactive(x)) {
x<-rlang::exec(x)
}
x
}
)
},
# no actual tests hereexpr= stopifnot(TRUE)
)
As is, this fails with:
Error in `map_vec()`:
! Can't convert `<list>[[1]]` <character> to <html>.
This makes sense to me: you can't convert a list to html.
(html is the S3 class assigned to returns by htmltools::HTML()).
What I don't understand is:
why modify_tree() (via map_vec()) would try to do this in the first place
why this wouldn't also affect the other examples
I'm not sure this is a bug, but it sure struck me as unexpected behavior.
(Or maybe I'm just being boneheaded and missing something).
My shiny module deals with inputs which can be a varying, nested list of reactives and non-reactives.
To deal with this list (show them) I first need to make all these leafs the same (i.e. rlang::exec() them and some other stuff).
The text was updated successfully, but these errors were encountered:
I ran into a very weird and subtle behavior involving
modify_tree()
on a list which includesshiny::reactive()
stake any of them away (
unclass()
the S3 class) or don't use a reactive, and the problem goes away.Here's the reprex:
As is, this fails with:
This makes sense to me: you can't convert a list to html.
(
html
is the S3 class assigned to returns byhtmltools::HTML()
).What I don't understand is:
modify_tree()
(viamap_vec()
) would try to do this in the first placeI'm not sure this is a bug, but it sure struck me as unexpected behavior.
(Or maybe I'm just being boneheaded and missing something).
session_info()
:Why though?
Fair question.
My shiny module deals with inputs which can be a varying, nested list of reactives and non-reactives.
To deal with this list (show them) I first need to make all these leafs the same (i.e.
rlang::exec()
them and some other stuff).The text was updated successfully, but these errors were encountered: