Novartis / tidymodules

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

Code snippets and helper functions #10

Open xni7 opened 4 years ago

xni7 commented 4 years ago

Related to the Add-in issue:

m-l-1 commented 4 years ago

@xni7 I am tempted to do that temporary but that add_module function should definitely be added to the {golem} package when we reach CRAN.

D3SL commented 4 years ago

As someone who's tried to use golem before I'd recommend not making it mandatory. I could never get it to work even after pulling my hair out for a week even though there was nothing wrong with the app itself. Imho I can't see the use of it, if you're deploying an app at scale odds are your company already has an internal SVN or the like.

That aside tidymodules looks like exactly what I'd been hoping for. I've tried to brute force shiny into heavily interactive CRUD work and it's a nightmare, even if you modularize it still turns into a hairball with tons of ctrl+f between the UI and server sections.

If I understand things right then in the most basic use case all someone needs to define are: Class name, input port, output port, UI element, and server element. And of those the UI and Server elements are pretty much the code straight from your existing app.r only with the addition of updating the output port in the server element, right?

So it sounds like you could make a wrapper for building very basic modules that works basically like Shiny itself does:

makeTidyModule(

input=list(
          name = "seed",
          description = "random number seed",
          sample = 123
),

output= list(
          name = "number",
          description = "Random number",
          sample = 123
),

ui = function(){},

server=function(){}

)

Essentially an souped up version of glue to let people fill in the basic vital sections without being scared by the extra syntax of defining a class.