mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
d1e64e910c
.Sample() is what .Throttle() sounds like it does. ProgressBar will be changed again, this implementation feels dirty.
35 lines
895 B
Plaintext
35 lines
895 B
Plaintext
@using Wabbajack.RateLimiter
|
|
@using System
|
|
@using System.Reactive.Linq
|
|
|
|
@namespace Wabbajack.App.Blazor.Components
|
|
|
|
<div id="progress-bar">
|
|
<progress value="@CurrentProgress"></progress>
|
|
<span class="text">@Text</span>
|
|
</div>
|
|
|
|
@code {
|
|
|
|
private double CurrentProgress { get; set; }
|
|
|
|
[Parameter] public IObservable<Percent> ProgressObserver { get; set; }
|
|
|
|
[Parameter] public string Text { get; set; }
|
|
|
|
protected override Task OnInitializedAsync()
|
|
{
|
|
var textPercentage = string.IsNullOrEmpty(Text);
|
|
ProgressObserver
|
|
.Sample(TimeSpan.FromMilliseconds(250))
|
|
.DistinctUntilChanged()
|
|
.Subscribe(p => {
|
|
CurrentProgress = p.Value;
|
|
if (textPercentage) Text = p.ToString();
|
|
InvokeAsync(StateHasChanged);
|
|
});
|
|
|
|
return base.OnInitializedAsync();
|
|
}
|
|
}
|