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

The spinner cannot show properly in the first run #132

Open
Molaison opened this issue Jan 13, 2023 · 1 comment
Open

The spinner cannot show properly in the first run #132

Molaison opened this issue Jan 13, 2023 · 1 comment

Comments

@Molaison
Copy link

Molaison commented Jan 13, 2023

I was using Waiter to show a spinner before the results were calculated. But I encountered a problem that the waiter component didn't show when the data was calculated for the first time.

The versions information of R and R packages I used are as follows:

R version 4.2.0 (2022-04-22 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)

Matrix products: default

locale:
[1] LC_COLLATE=Chinese (Simplified)_China.utf8 
[2] LC_CTYPE=Chinese (Simplified)_China.utf8   
[3] LC_MONETARY=Chinese (Simplified)_China.utf8
[4] LC_NUMERIC=C                               
[5] LC_TIME=Chinese (Simplified)_China.utf8    

attached base packages:
[1] parallel  stats     graphics  grDevices datasets  utils     methods   base     

other attached packages:
 [1] shinycssloaders_1.0.0 waiter_0.2.5          forcats_0.5.2        
 [4] readr_2.1.2           tidyverse_1.3.2       shinyBS_0.61.1       
 [7] shinyWidgets_0.7.5    shinyjs_2.1.0         shinyalert_3.0.0     
[10] DT_0.24               jsonlite_1.8.4        xml2_1.3.3           
[13] rvest_1.0.3           httr_1.4.4            shinydashboard_0.7.2 
[16] MantaID_1.0.2         rpart_4.1.16          xgboost_1.6.0.1      
[19] ranger_0.14.1         ggcorrplot_0.1.4      RColorBrewer_1.1-3   
[22] tidyselect_1.2.0      tidyr_1.2.0           tibble_3.1.8         
[25] stringr_1.4.1         scutr_0.1.2           reshape2_1.4.4       
[28] purrr_1.0.0           mlr3learners_0.5.1    mlr3tuning_0.13.1    
[31] paradox_0.10.0        mlr3_0.13.4           magrittr_2.0.3       
[34] keras_2.11.0          dplyr_1.0.9           data.table_1.14.2    
[37] caret_6.0-93          lattice_0.20-45       ggplot2_3.4.0        
[40] biomaRt_2.54.0        shiny_1.7.4          

loaded via a namespace (and not attached):
  [1] utf8_1.2.2             R.utils_2.12.2         reticulate_1.26       
  [4] RSQLite_2.2.20         AnnotationDbi_1.60.0   htmlwidgets_1.5.4     
  [7] grid_4.2.0             mlr3misc_0.11.0        pROC_1.18.0           
 [10] sourcetools_0.1.7      munsell_0.5.0          codetools_0.2-18      
 [13] bbotk_0.7.2            future_1.27.0          withr_2.5.0           
 [16] colorspace_2.0-3       Biobase_2.58.0         filelock_1.0.2        
 [19] uuid_1.1-0             rstudioapi_0.14        stats4_4.2.0          
 [22] tensorflow_2.11.0      listenv_0.8.0          labeling_0.4.2        
 [25] GenomeInfoDbData_1.2.9 lgr_0.4.3              farver_2.1.1          
 [28] bit64_4.0.5            rprojroot_2.0.3        parallelly_1.32.1     
 [31] vctrs_0.5.1            generics_0.1.3         ipred_0.9-13          
 [34] BiocFileCache_2.6.0    R6_2.5.1               GenomeInfoDb_1.34.6   
 [37] mlr3measures_0.5.0     bitops_1.0-7           cachem_1.0.6          
 [40] assertthat_0.2.1       promises_1.2.0.1       scales_1.2.1          
 [43] vroom_1.5.7            nnet_7.3-17            googlesheets4_1.0.1   
 [46] gtable_0.3.1           globals_0.16.1         timeDate_4021.107     
 [49] rlang_1.0.6            zeallot_0.1.0          splines_4.2.0         
 [52] ModelMetrics_1.2.2.2   gargle_1.2.0           smotefamily_1.3.1     
 [55] broom_1.0.1            checkmate_2.1.0        yaml_2.3.5            
 [58] modelr_0.1.9           crosstalk_1.2.0        backports_1.4.1       
 [61] rsconnect_0.8.28       httpuv_1.6.7           tools_4.2.0           
 [64] lava_1.7.0             ellipsis_0.3.2         jquerylib_0.1.4       
 [67] BiocGenerics_0.44.0    Rcpp_1.0.9             plyr_1.8.7            
 [70] base64enc_0.1-3        progress_1.2.2         zlibbioc_1.44.0       
 [73] RCurl_1.98-1.9         prettyunits_1.1.1      openssl_2.0.2         
 [76] S4Vectors_0.36.1       fontawesome_0.4.0      haven_2.5.1           
 [79] fs_1.5.2               here_1.0.1             reprex_2.0.2          
 [82] googledrive_2.0.0      whisker_0.4.1          R.cache_0.16.0        
 [85] hms_1.1.2              mime_0.12              xtable_1.8-4          
 [88] XML_3.99-0.13          mclust_6.0.0           readxl_1.4.1          
 [91] IRanges_2.32.0         tfruns_1.5.1           compiler_4.2.0        
 [94] crayon_1.5.2           R.oo_1.25.0            htmltools_0.5.4       
 [97] later_1.3.0            tzdb_0.3.0             lubridate_1.8.0       
[100] DBI_1.1.3              dbplyr_2.2.1           MASS_7.3-58.1         
[103] rappdirs_0.3.3         Matrix_1.4-1           cli_3.5.0             
[106] R.methodsS3_1.8.2      gower_1.0.1            pkgconfig_2.0.3       
[109] recipes_1.0.3          foreach_1.5.2          bslib_0.4.2           
[112] hardhat_1.2.0          XVector_0.38.0         prodlim_2019.11.13    
[115] digest_0.6.31          Biostrings_2.66.0      cellranger_1.1.0      
[118] curl_4.3.3             lifecycle_1.0.3        nlme_3.1-159          
[121] askpass_1.1            fansi_1.0.3            pillar_1.8.1          
[124] KEGGREST_1.38.0        fastmap_1.1.0          survival_3.4-0        
[127] glue_1.6.2             png_0.1-8              iterators_1.0.14      
[130] bit_4.0.5              class_7.3-20           stringi_1.7.8         
[133] sass_0.4.4             blob_1.2.3             palmerpenguins_0.1.1  
[136] memoise_2.0.1          renv_0.16.0            styler_1.8.1          
[139] future.apply_1.9.0 

To demonstrate the issue more clearly, I have prepared a shiny reprex below.

ui <- fluidPage(
  useWaiter(),
  actionButton("run", "RUN"),
  DTOutput("DTtest")
)

server <- function(input, output, session) {
  wtr_test <- Waiter$new(id = "DTtest", html = spin_dots())
  DT_result <- eventReactive(input$run, {
    wtr_test$show()
    on.exit({
      wtr_test$hide()
    })
    Sys.sleep(5)
    iris
  })
  output$DTtest <- renderDataTable(
    DT_result()
  )
}

shinyApp(ui, server)
@JohnCoene
Copy link
Owner

The first time you click "run" the DT is not present on screen, waiter cannot overlay anything, subsequent time it works fine.

Consider this below if you want this to show all the time.

library(DT)
library(shiny)

ui <- fluidPage(
  useWaiter(),
  actionButton("run", "RUN"),
  div(
    style = "min-height:400px",
    id = "DTtest-container",
    DTOutput("DTtest")
  )
)

server <- function(input, output, session) {
  wtr_test <- Waiter$new(id = "DTtest-container", html = spin_dots())
  DT_result <- eventReactive(input$run, {
    wtr_test$show()
    on.exit({
      wtr_test$hide()
    })
    Sys.sleep(5)
    iris
  })
  output$DTtest <- renderDT(
    DT_result()
  )
}

shinyApp(ui, server)

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