rstudio / shinymeta

Record and expose Shiny app logic using metaprogramming
https://rstudio.github.io/shinymeta
223 stars 14 forks source link

Can function contents be captured? #118

Closed JanionNevill closed 6 months ago

JanionNevill commented 6 months ago

Hi, I'm working on an app which contains a lot of code for making custom plots for which I am looking to export a reproducible script. Since the code is fairly complex, it is factored out into functions which are called by the renderPlot() function.

When I wrap the render call in metaRender() and the required ..() calls, I get a script which calls the custom function, but that function is not captured anywhere. I am aware that this might be outside of the scope of this package, but is there any way to capture the custom function without moving the code back inside a render or reactive function?

I have considered making my custom functions into a package, but that doesn't quite address my use case of allowing users to make tweaks to the plots where adding more options is not practical.

Thanks Janion

jcheng5 commented 6 months ago

I believe you can put your function definitions in a funcs <- metaAction({ … }). Then include funcs() as an argument to expandChain.

JanionNevill commented 6 months ago

That's exactly what I was looking for, thanks.