Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add isolate when data[[...]]() is used in a UI function so modules can be used outside of teal::init #743

Closed
nikolas-burkoff opened this issue Oct 4, 2022 · 2 comments
Labels

Comments

@nikolas-burkoff
Copy link
Contributor

nikolas-burkoff commented Oct 4, 2022

From here

This app works (on teal_refactor@main if not yet merged in) but only because of e.g. here - this should be done throughout the code base and docs updated in teal for creating your own modules.

image

library(teal.modules.general)
library(shiny)

data <- new_tdata(list(iris = iris))

var_brow <- tm_variable_browser()
dat_tab <- tm_data_table()

ui <- fluidPage(
  fluidRow(
    column(8, do.call(var_brow$ui, c(list(id = "id_1", data = data), var_brow$ui_args))),
    column(4, do.call(dat_tab$ui, c(list(id = "id_2", data = data), dat_tab$ui_args)))
  )
)

server <- function(input, output, session) {
  do.call(var_brow$server, c(list("id_1", data = data), var_brow$server_args))
  do.call(dat_tab$server, c(list("id_2", data = data), dat_tab$server_args))
}

shinyApp(ui, server)

A separate issue could be created to simplify calling modules outside of teal as the above is clunky

@donyunardi
Copy link
Contributor

donyunardi commented Nov 2, 2022

Definition of Done

  • Implement dataset <- isolate(data[[x]]()) to all UI function in modules packages only when you're evaluating the reactive in the UI. (search for data[[...]]() and add isolate there.
  • If the data argument is not in the UI function, then it's possible that nothing needs to be done.
  • User can run the module using shinyApp().

@nikolas-burkoff
Copy link
Contributor Author

Closing this as the only modules throughout the codebase which have data in the ui function are

  • variable_browser already fixed
  • datatable already fixed
  • missing data - does not need fixing as only names(data) is used not data[...]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants