Add refresh button and automatic refreshing timer to update state.
As effect, this keeps updating the amount of people online.
This commit is contained in:
parent
b041d7d244
commit
2da0063331
@ -1,3 +1,5 @@
|
||||
@using System.Threading;
|
||||
|
||||
<table class="table table-striped">
|
||||
<RepeaterComponent Items="this.servers">
|
||||
<Header>
|
||||
@ -21,8 +23,11 @@
|
||||
</RepeaterComponent>
|
||||
</table>
|
||||
|
||||
<button type="button" class="btn btn-primary" onclick=@(() => {base.InvokeAsync(StateHasChanged);})"">Refresh</button>
|
||||
|
||||
@code {
|
||||
private List<Server>? servers;
|
||||
private Timer? Timer;
|
||||
|
||||
[Parameter]
|
||||
public string? CityName { get; set; }
|
||||
@ -80,6 +85,10 @@
|
||||
}
|
||||
// Render the component again by letting it know the state changed.
|
||||
StateHasChanged();
|
||||
|
||||
Timer = new Timer(_ => {
|
||||
base.InvokeAsync(StateHasChanged);
|
||||
}, null, 4000, 4000);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user