ColinFay / gargoyle

Event-Based Structures for 'Shiny'
Other
55 stars 7 forks source link

trigger doesn't work when watch is not imported #2

Closed BenjaminLouis closed 1 year ago

BenjaminLouis commented 3 years ago

Hey Colin,

Thanks for this package which is really cool to deal with reactivity in shiny apps, in particular when we use module like with the golem framework.

I am developping a golem app and I started by using your function that I borrowed from your hexmake app and it works well. Now that gargoyle is on CRAN I am changing the code by importing the needed functions. I never use watch() but only trigger() and on() (and obviously init()). After removing the internal function and switch to @importFrom gargoyle trigger on init it didn't work anymore. I figured the problem out by adding watch() in the @importFrom gargoyle section even if I never use directly the watch() function

I am under the impression that I shouldn't have to add watch() because it is included in on() function, but maybe I am wrong. What do you think?

Thanks

DavidJesse21 commented 2 years ago

Hi Colin, thank you also from my side for this simple yet very helpful package :) I have recently discovered this problem, too, as I usually use the gargoyle functions via its explicit namespace (i.e. gargoyle::init(...), gargoyle::watch(...), etc.).

The problem with the gargoyle::on() function must occur in this line of code: https://github.com/ColinFay/gargoyle/blob/e0398a6970c5e43e081472e594fc13d1704bd938/R/funs.R#L139

I guess because the watch function is inside of substitute it's not "seen" when building the package and hence it must be attached first in order to work for the user. Maybe replacing watch with gargoyle::watch inside of substitute() already solves this problem?

Best regards David

ColinFay commented 1 year ago

closed via #5