Skip to content

Update Messages Alongside Hostess Progress #149

@jmestret

Description

@jmestret

Hi!
First of all, thank you for developing such a useful package. I have a problem with using Hostess and dynamic text. I have successfully implemented dynamic messages with the spinner. However, my current approach feels somewhat inelegant, and I'm wondering if there is a cleaner alternative. The problem arises when trying to switch from the spinner to a Hostess loader while simultaneously updating messages. Is it possible to update messages while updating the Hostess progress?

I am attaching below the method I used with the spinner.

Thank you very much!

library(shiny)
library(waiter)

ui <- fluidPage(
    useWaiter(),
    actionButton("show", "Show loading with updates")
)

server <- function(input, output, session){
    # create the waiter
    waiting_screen <- tagList(
        spin_flower(),
        h4("Cool stuff loading...")
    )
    w <- Waiter$new(html = waiting_screen)
    
    msgs <- c("Loading data", "Running model", "Drawing plots")
    
    observeEvent(input$show, {
        w$show()
        
        Sys.sleep(2)
        
        for(i in 1:3){
            w$update(html = tagList(
                spin_flower(),
                h4(msgs[i])
            ))
            Sys.sleep(2)
        }
        
        w$hide()
    })
}

shinyApp(ui, server)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions