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

[Feature Request]: create functions to have template for application. #1034

Closed
3 tasks done
kartikeyakirar opened this issue Jan 9, 2024 · 2 comments
Closed
3 tasks done
Assignees
Labels
core discussion enhancement New feature or request

Comments

@kartikeyakirar
Copy link
Contributor

Feature description

To enhance the user experience and provide a more straightforward starting point for those new to teal, there could be template functions into the application. These templates, was discussed last week into daily so I am putting this up for discussion. this template might an additional aid to tutorial videos which @vedhav is working on , aim to simplify the initial steps for new users.

The idea is to create default application templates with minimal parameters needed for initialization. These templates will include pre-written function calls from different tea_*l packages and create skeleton for teal app based on user requirement showcasing teal products. They will feature placeholders and comments guiding users on where and how to insert their logic, offering a hands-on approach to getting started with the application.

This function will encapsulate functionality from various packages and call necessary libraries Below is a sample template showcasing how a teal application template might look like.
e.g sample_teal_template(reporter =T, custom_moule = T, ...)

library(teal)

## defining teal_data
data <- within(teal_data(), {
  #TODO logic to create teal_data
  #TODO add reproducible code.
})

## defining custom module

# UI function for the module
ui_custom_example <- function(id) {
  ns <- NS(id)
  teal.widgets::standard_layout(
    output = #object with the output element,
    encoding = #object containing the encoding elements,
    forms = teal.widgets::verbatim_popup_ui(ns("rcode"), "Show R code")
  )
}

# Server function for the module
srv_custom_example <- function(id, data) {
  checkmate::assert_class(data, "reactive")
  checkmate::assert_class(isolate(data()), "teal_data")
  
  moduleServer(id, function(input, output, session) {
    ns <- session$ns
    
    # Plots and data.frame display logic
    #TODO
    
    # Code upon clicking 'Show R Code' button
    teal.widgets::verbatim_popup_srv(
      id = "rcode",
      verbatim_content = reactive(teal.code::get_code(plot_code_q())),
      title = "R Code"
    )
  })
}

# Function that creates module instance for use in `teal` app
custom_module <- function(label = "<custom module title>") {
  module(
    label = label,
    server = srv_custom_example,
    ui = ui_custom_example,
    datanames = "all"
  )
}

# Define filters
filters <- teal_slices(
  teal_slice(dataname = "<dataname>", varname = "<varname>", id = "<id>"),
  module_specific = TRUE,
  mapping = list(
    global_filters = "<id>"
  )
)

## App initialization
app <- init(
  data = data,
  modules = custom_module(),
  filters = filters
)

if (interactive()) shinyApp(app$ui, app$server)

This proposal aims to streamline the learning curve for new users by providing them with a practical and editable framework to build their teal application.

I'd like to open up a discussion on whether adding these functions would be beneficial, or if our current vignettes and tutorials sufficiently meet our needs.

Code of Conduct

  • I agree to follow this project's Code of Conduct.

Contribution Guidelines

  • I agree to follow this project's Contribution Guidelines.

Security Policy

  • I agree to follow this project's Security Policy.
@pawelru
Copy link
Contributor

pawelru commented Jan 9, 2024

This topic seems familiar to me - please have a look at linked issues / PRs -> insightsengineering/NEST-roadmap#9

As far as I recall, we abandoned it and leave a complete freedom to our users.

@kartikeyakirar
Copy link
Contributor Author

Okay, closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core discussion enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants