Problem
To access a reactiveValues with character vector doesn't work.
isolate(rv[[c("a1","b1")]]) # Error: Must use single string to index into reactivevalues.
I would like to create a function which allows to access the nested reactiveValues generically:
#' returns value at index
#'
#' @param rv reactiveValues()
#' @param field character vector
#'
#' @return value at index
access_rv = function(rv,field){
# ...
}
#' returns value at index
#'
#' @param rv reactiveValues()
#' @param field character vector
#'
#' @return value at index
access_rv = function(rv,field){
isolate(purrr::pluck(rv, !!!field))
}
access_rv(rv,c("a1","b1")) # works, return "b1"
and also
set_rv = function(rv,field,value){
isolate(purrr::pluck(rv, !!!field) <- value )
}
set_rv(rv,c("a1","b1"),"c1") # works
access_rv(rv,c("a1","b1")) # works, return "c1"