Skip to content

Commit

Permalink
Remove soft deprecated function bookmarkableShinyApp (#782)
Browse files Browse the repository at this point in the history
Closes [this](#756).

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
chlebowa and github-actions[bot] authored Nov 24, 2022
1 parent e523e4b commit dfc37de
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 164 deletions.
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ S3method(ui_nested_tabs,default)
S3method(ui_nested_tabs,teal_module)
S3method(ui_nested_tabs,teal_modules)
export("%>%")
export(bookmarkableShinyApp)
export(example_module)
export(get_code_tdata)
export(get_join_keys)
Expand Down
5 changes: 1 addition & 4 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
* Updated examples to use `scda.2022`.
* Added R session information into a link in the footer of `teal` applications.
* Added data hashing step using `rlang` instead of `digest` package to calculate the hash (which has been moved from `teal.data` and `teal.slice`). There is now an explicit hashing check in the reproducible code output.
* Removed deprecated function `default_filter`.
* Removed deprecated logging mechanism, including the functions `log_app_usage` and `.log`.
* Removed deprecated functions: `root_modules`, `default_filter`, `bookmarkableShinyApp`, as well as deprecated logging mechanism, including the functions `log_app_usage` and `.log`.

# teal 0.12.0

Expand All @@ -30,13 +29,11 @@
* Updated `teal_module` to have `filter_panel_api` argument which receives a `FilterPanelAPI` object.
* Updated the internals of `module_teal` to reflect changes in `teal.slice`.


### Breaking changes

* Updated `teal_module` to no longer receive `datasets` object in the `...` argument. In order to use `datasets` in the `teal_module` please specify `datasets` explicitly.
* Deprecated `merge_expression` argument in `get_rcode_srv` function and removed it in `get_rcode` function.
* Deprecated `session` argument in `get_rcode` function.
* Removed the deprecated function `root_module`.

# Miscellaneous

Expand Down
70 changes: 0 additions & 70 deletions R/init.R
Original file line number Diff line number Diff line change
Expand Up @@ -188,73 +188,3 @@ init <- function(data,
logger::log_trace("init teal app has been initialized.")
return(res)
}


#' Make a Shiny UI function bookmarkable
#'
#' @description `r lifecycle::badge("deprecated")`
#'
#' This function is deprecated and will be removed in a future release of `teal`.
#'
#' This is a customization of `shinyApp`.
#'
#' To be bookmarkable, the Shiny UI function must have an
#' argument `request`. This function ensures this.
#'
#' When `ui` is a function, it passes the following to `shinyApp`
#' ```
#' app <- teal::init(....)
#' ui <- app$ui
#' ui_new <- function(request) {
#' ui() # or just `ui` when ui is already evaluated, e.g. `shiny.tag`
#' }
#' ```
#'
#' If no bookmarking is needed for teal apps, then you can also call
#' `shinyApp(ui = app$ui, server = app$server)`, where `app` is returned
#' by `init()`.
#'
#' **For Developers: **
#' The reason you cannot
#' call `shinyApp(ui = app$ui, server = app$server)` without parentheses is
#' that `app$ui` has an `id` argument with a default value which makes it
#' possible to be added into modules. `shinyApp` thinks that this is the request
#' argument which is needed for bookmarking. This avoids it.
#'
#' We guarantee that anything that can be run with `shinyApp` can be replaced
#' by a call to this function without any changes.
#'
#' @param ui `function or shiny.tag` Shiny UI; either a
#' `shiny.tag` or a function with no argument or
#' one argument (`request`)
#' @param server `function` Shiny server function
#' @param ... additional arguments to `shinyApp`
#' @return `shinyApp` value
#' @export
bookmarkableShinyApp <- function(ui, server, ...) { # nolint

# Note when this function is removed code to allow bookmarking in srv_teal
# should also be removed.
lifecycle::deprecate_soft(
when = "0.12.0",
what = "bookmarkableShinyApp()",
details = "In future releases teal will stop supporting shiny bookmarking"
)

# ui must be a function of request to be bookmarkable
ui_new <- function(request) {
# we use similar logic to `shiny:::uiHttpHandler`
if (is.function(ui)) {
# evaluating ui with default arguments
ui()
} else {
checkmate::assert(
checkmate::check_class(ui, "shiny.tag"),
checkmate::check_class(ui, "shiny.tag.list"),
checkmate::check_class(ui, "html")
)
ui
}
}
return(shinyApp(ui = ui_new, server = server, ...))
}
34 changes: 0 additions & 34 deletions R/module_teal.R
Original file line number Diff line number Diff line change
Expand Up @@ -157,36 +157,6 @@ srv_teal <- function(id, modules, raw_data, filter = list()) {
}
)

# bookmarking -----
# Note bookmarkableShinyApp has been soft deprecated and when it has been removed completely
# this code should be removed.
saved_datasets_state <- reactiveVal(NULL) # set when restored because data must already be populated
onBookmark(function(state) {
# this function is isolated by Shiny
# We store the entire R6 class with reactive values in it, but set the data to NULL.
# Note that we cannnot directly do this on datasets as this would trigger
# reactivity to recompute the filtered datasets, which is not needed.
logger::log_trace(
paste(
"srv_teal@2 saving active filter state for",
"datasets: { paste(names(datasets_reactive()$get_filter_state()), collapse = ' ') }."
)
)
state$values$datasets_state <- datasets_reactive()$get_filter_state()
})
onRestore(function(state) {
# The saved datasets mainly contains the filter states as the data
# was set to NULL before storing. The data should have been set again
# by the user, so we just need to set the filters.
logger::log_trace(
paste(
"srv_teal@3 restoring filter states from the bookmark for",
"datasets: { paste(names(state$values$datasets_state), collapse = ' ') }."
)
)
saved_datasets_state(state$values$datasets_state)
})

# loading the data -----
env <- environment()
datasets_reactive <- reactive({
Expand Down Expand Up @@ -236,10 +206,6 @@ srv_teal <- function(id, modules, raw_data, filter = list()) {
immediate = TRUE
)

# switching filter to bookmarked state
if (!is.null(saved_datasets_state())) filter <- saved_datasets_state()


# must make sure that this is only executed once as modules assume their observers are only
# registered once (calling server functions twice would trigger observers twice each time)
active_module <- srv_tabs_with_filters(
Expand Down
1 change: 0 additions & 1 deletion _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ reference:
- starts_with("validate_")
- title: Deprecated functions
contents:
- bookmarkableShinyApp
- get_rcode
- get_rcode_srv
- get_rcode_ui
Expand Down
1 change: 0 additions & 1 deletion inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ UIs
Ui
UX
anl
bookmarkable
cdisc
css
customizable
Expand Down
53 changes: 0 additions & 53 deletions man/bookmarkableShinyApp.Rd

This file was deleted.

0 comments on commit dfc37de

Please sign in to comment.