Shared Functions in Modules

This is a conceptual question that I have not come across an answer for yet. (Apologies if it has been answered and I have missed it.)

In Shiny apps, the scripts in the R folder are run before the app.R file, so functions in separate files are loaded and don't need to be specifically sourced. Should modules reference/load files in the R folder or any external files? Or should they be completely independent of other files? I always see modules referred to as black boxes, so my guess is no, they should not.

I'm asking because there are some functions that I use inside and outside of the modules in my app and want to know what the best practice is.

Thanks!

If your shiny module would benefit from being able to call a helpful function, it should do so, same as if you were calling a function from a library, or base R. Just be sure that you are writing clean/black box functions, and not ones that themselves rely on global state etc.

I didn't think of thinking of it like a package, that's a great point.

Thanks!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.