Novartis / tidymodules

An Object-Oriented approach to Shiny modules
https://opensource.nibr.com/tidymodules
Other
143 stars 11 forks source link

Issue 10 snippet helper #28

Closed m-l-1 closed 4 years ago

m-l-1 commented 4 years ago

10

DivadNojnarg commented 4 years ago

Started to test:

Maybe add a slot for nested modules as well as:

# module R6Class ---------------------------------

#' R6 Class representing the module
#'
#' @description
#' UI and server code necessary for the module
#' @details
#' More details
#'
#' @export
module <- R6::R6Class(
  "module",
  inherit = tidymodules::TidyModule,
  public = list(
    #' @field nested_mod nested modules. This is updated by the initialize function.
    nested_mod = list(),

    #' @description
    #' Module initialization
    #' @param ... NULL by default.
    #' @return A new `module` object.
    initialize = function(...) {
      super$initialize(...)

      # initialize nested modules
      # self$nested_mod[[1]] <- Nested$new(inherit = TRUE)

      # define ports
      self$definePort({

      })

    },

    #' @description
    #' Create the module UI
    #' @return ...
    ui = function() {
      tagList(
        # UI elements go here
      )
    },

    #' @description
    #' Server function description
    #' @param input Shiny input object.
    #' @param output Shiny output object.
    #' @param session Shiny session object.
    #' @return The server function.
    server = function(input, output, session) {

      super$server(input, output, session)

      # call all nasted modules below
      # self$nested_mod[[1]]$callModule()

      # update output ports
      self$assignPort({
        # self$updateOutputPort(...)
      })

    }
  )
)
DivadNojnarg commented 4 years ago

Second test fails:

tidymodules::add_tm_snippets():

Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") :
cannot open file '/home/rstudio-user/.R/snippets/r.snippets': No such file or directory