daattali / shinycssloaders

⌛ Add loading animations to a Shiny output while it's recalculating
https://daattali.com/shiny/shinycssloaders-demo/
Other
395 stars 45 forks source link

function from shinycssloaders::withSpinner -argument "ui_element" is missing, with no default #66

Closed williamlai2 closed 2 years ago

williamlai2 commented 2 years ago

Hi,

This is more a question than an issue.

I am trying to create a function from the withSpinner() function.

add_spinner <- function(spinner_colour = "#277BB4", spinner_type = 8){

  shinycssloaders::withSpinner(color = spinner_colour, type = getOption("spinner.type", default = spinner_type))
}

I am trying to use it in a function in a module like this:

leafletOutput("map") %>%
                          add_spinner()

But I get this error:

Error in digest::digest(ui_element) : argument "ui_element" is missing, with no default

I am wondering if you know how to fix this? In your withSpinner() code, ui_element is the first argument, and I thought that this would be piped in from the map. Thanks.

daattali commented 2 years ago

You aren't passing in the parameter into the withSpinner function. It seems you're having trouble with the concept of creating functions with pipes, this isn't a shiny related question or specific to this package. I suggest you try creating other "wrapper" functions with pipes and learn how to do that correctly, with regular non shiny R code, and then come back to this. I'm closing this issue as it's unrelated to this package.

williamlai2 commented 2 years ago

Sure. Will have a look.