Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move shiny::addResourcePath to .onLoad() #100

Open
riccardoporreca opened this issue Jul 25, 2018 · 1 comment
Open

Move shiny::addResourcePath to .onLoad() #100

riccardoporreca opened this issue Jul 25, 2018 · 1 comment

Comments

@riccardoporreca
Copy link

shinyBS resource publishing via shiny::addResourcePath is only performed .onAttach() and not .onLoad()

shinyBS/R/misc.R

Lines 1 to 6 in c329f8c

.onAttach <- function(...) {
# Create link to javascript and css files for package
shiny::addResourcePath("sbs", system.file("www", package="shinyBS"))
}

This can cause problems for Shiny apps which do not load attach shinyBS but only load its namespace (e.g., apps shipped as part of packages, with strict control over dependencies).

See related issues #92 and yonicd/ggedit#17 and comments therein.

@IvoryC
Copy link

IvoryC commented Mar 23, 2021

I converted my shiny app into an R package and I was SO confused about why my tips and popovers stopped working. And I really liked all my tips and popovers!

Calling library(shinyBS) would fix it...but then my package check command didn't pass. : (
And I shouldn't need that, I used shinyBS:: in front of all my calls to shinyBS functions.

Chipping at it, I found that adding this line to my server function brought the functionality back:
shiny::addResourcePath("sbs", system.file("www", package="shinyBS"))}
Yay! : )

The .onLoad() solution sounds reasonable to me, but I don't know all of the consequences of using .onAttach() vs .onLoad(); so I can't say if that is the best solution. What I CAN say is: please count my experience as an up-vote of the fact that there is a real problem in the current setup.

If for some reason you don't like the .onLoad() approach, something like a shinyBS::useShinyBS() call might work. That would be analogous to the shinyFeedback::useShinyFeedback() or shinyjs::useShinyjs() lines required by other packages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants