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">
|
<table class="table table-striped">
|
||||||
<RepeaterComponent Items="this.servers">
|
<RepeaterComponent Items="this.servers">
|
||||||
<Header>
|
<Header>
|
||||||
@ -21,8 +23,11 @@
|
|||||||
</RepeaterComponent>
|
</RepeaterComponent>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
<button type="button" class="btn btn-primary" onclick=@(() => {base.InvokeAsync(StateHasChanged);})"">Refresh</button>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private List<Server>? servers;
|
private List<Server>? servers;
|
||||||
|
private Timer? Timer;
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public string? CityName { get; set; }
|
public string? CityName { get; set; }
|
||||||
@ -80,6 +85,10 @@
|
|||||||
}
|
}
|
||||||
// Render the component again by letting it know the state changed.
|
// Render the component again by letting it know the state changed.
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
|
|
||||||
|
Timer = new Timer(_ => {
|
||||||
|
base.InvokeAsync(StateHasChanged);
|
||||||
|
}, null, 4000, 4000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user