Skip to content

Instantly share code, notes, and snippets.

@ctrl-alt-d
ctrl-alt-d / index.razor
Created Mar 2, 2021
Blazor server sending 500 upates per second
View index.razor
@page "/"
Tics per second: <input type="range" min="1" max="500" @bind="@CurrentValue" class="slider" id="myRange"> @CurrentValue
<br/><br/>
<div style="width:500px; height:10px; background-color: blue; position: relative;">
<div class="ball" style="@position_txt"></div>
</div>
<br/><br/>
<span>@DateTime.Now.ToString("HH:mm:ss")</span>
<span>Number of renders: @nRenders.ToString("N0")</span>
<br/><br/>
@ctrl-alt-d
ctrl-alt-d / MyGrid.razor
Created Mar 29, 2020
Cache for data grid component
View MyGrid.razor
[Parameter]
public IEnumerable<object> DataSource {set; get; }
private IEnumerable<object> Cache {set; get; } = null;
List<MyColumn> Columns = new List<MyColumn>();
public void AddColumn(MyColumn column)
{
var seg = DataSource;
Cache ??= DataSource.ToList();
DataSource = Cache;