Using UDPreloader

Any ideas on how to get a preloader to work with something that is not a endpoint continuously running, it’s only launched on demand when the element is requested? I’ve been throwing it around and getting different effects but not the one I’m looking for where the card has a spinning icon for content, then is replaced with the desired data when available?

Haven’t seen too many examples using this component yet :frowning:

New-UDColumn -Size 6 -Content {
    $Cache:loading = $true
    If ($Cache:loading -eq $true) {
        New-UDCard -Title "Graylog Online Status" -Endpoint {
            New-UDPreloader -Circular -Color blue
            $GraylogWebStatuses = Get-GraylogOnlineStatus 
#This sets `$Cache:Loading = $false` just before returning the result
        }    
    }
    Else {
         New-UDCard -Title "Graylog Online Status" -Endpoint {
             $GraylogWebStatuses
         }
    }
}

Using Sync-Element, you could hide the preloader element based on your $Cache:loading variable.

Take a look at this gist from @MadWithPowerShell for an example.

2 Likes

Thanks @itfranck! I never would have thought of that but it makes a ton of sense! Appreciate it!