Anyone leveraged New-UDPreloader?

Hi guys, have a scenario where I’m fetching all sorts of data so my dynamic page looks lonely before it returns there data, I see that we have an option to use New-UDPreloader but unsure of how to use, anyone use this? What are others doing for these cases where load times could be 20sec+ of silence for the user?

Thanks,

1 Like

New-UDPreloader is not effective like write-progress in powershell, so its kind off workaround so far but u can use as per the developer example below

if ($Cache:Data -eq $null) {
New-UDPreloader
}
else {
New-UDChart -Endpoint { $Cache:Data … }
}

3 Likes

Baybe this will help:

2 Likes

Thanks @psott @wsl2001 … I’ll see how to integrate this in my code. I’ll follow up on how that goes. I like the way UDinput uses circular preload button click is triggered, would like to implement the same for when endpoints and any point where data retrieval is being executed would be ideal.

Just as an extension to the snippet @psott provided, if you did want to leverage New-UDPreloader you could use something like the below:

** Keep in mind this example doesn’t let you specify a percentage remaining however.

$Page_Home = New-UDPage -Name 'Home' -Icon home -Content {
    New-UDRow -Endpoint {
        if($Cache:Loading -eq $true) {
            New-UDElement -Tag 'div' -Content { 
                New-UDPreloader -Color blue -Size large -Circular
            } -Attributes @{
                style = @{
                    position = 'fixed'
                    top = '50%'
                    left = '50%'
                }
            }
        } 
    } -AutoRefresh -RefreshInterval 1
         
    New-UDRow -Endpoint {
        $Cache:Loading = $true
        #Do Stuff...
        $Cache:Loading = $false
    }
}
3 Likes