Wrap a shiny ui in this function in order to add cookie-handling
functionality. The ui can be defined in any format compatible with shiny,
using functions such as shiny::fluidPage()
, shiny::bootstrapPage()
,
shiny::htmlTemplate()
, or a raw HTML string.
Arguments
- ui
A 0- or 1-argument function defining the ui of a shiny app, or a
shiny::tagList()
.
Value
An object with the same signature as the input ui
, but with the
dependencies needed to handle cookies. If ui
is a shiny::tagList()
, a
shiny::tagList()
will be returned; if ui
is a function, a function will
be returned.
Examples
str(add_cookie_handlers("example"))
#> List of 2
#> $ :List of 2
#> ..$ :List of 10
#> .. ..$ name : chr "js-cookie"
#> .. ..$ version : chr "3.0.1"
#> .. ..$ src :List of 2
#> .. .. ..$ href: chr "https://cdn.jsdelivr.net/npm/js-cookie/dist/"
#> .. .. ..$ file: chr "js"
#> .. ..$ meta : NULL
#> .. ..$ script : chr "js.cookie.min.js"
#> .. ..$ stylesheet: NULL
#> .. ..$ head : NULL
#> .. ..$ attachment: NULL
#> .. ..$ package : chr "cookies"
#> .. ..$ all_files : logi TRUE
#> .. ..- attr(*, "class")= chr "html_dependency"
#> ..$ :List of 10
#> .. ..$ name : chr "cookie_input"
#> .. ..$ version : chr "1.0.0"
#> .. ..$ src :List of 1
#> .. .. ..$ file: chr "js"
#> .. ..$ meta : NULL
#> .. ..$ script : chr "cookie_input.js"
#> .. ..$ stylesheet: NULL
#> .. ..$ head : NULL
#> .. ..$ attachment: NULL
#> .. ..$ package : chr "cookies"
#> .. ..$ all_files : logi TRUE
#> .. ..- attr(*, "class")= chr "html_dependency"
#> $ : chr "example"
#> - attr(*, "class")= chr [1:2] "shiny.tag.list" "list"