39 lines
718 B
C#
Raw Normal View History

2021-09-01 20:39:43 +09:00
using Microsoft.AspNetCore.Components;
2021-09-02 16:37:20 +09:00
using ObservableCollections;
2021-09-01 20:39:43 +09:00
namespace BlazorApp.Pages;
2021-09-03 18:26:37 +09:00
public partial class Index : IDisposable
2021-09-01 20:39:43 +09:00
{
2021-09-02 16:37:20 +09:00
ObservableList<int> list;
public ISynchronizedView<int, int> ItemsView { get; set; }
int adder = 99;
2021-09-01 20:39:43 +09:00
2021-09-02 16:37:20 +09:00
protected override void OnInitialized()
{
list = new ObservableList<int>();
2021-09-03 18:26:37 +09:00
ItemsView = list.CreateView(x => x);
2021-09-02 16:37:20 +09:00
2021-09-03 18:26:37 +09:00
ItemsView.CollectionStateChanged += action =>
2021-09-02 16:37:20 +09:00
{
2021-09-03 18:26:37 +09:00
InvokeAsync(StateHasChanged);
2021-09-02 16:37:20 +09:00
};
}
2021-09-03 18:26:37 +09:00
public void Dispose()
{
ItemsView.Dispose();
}
2021-09-02 16:37:20 +09:00
void OnClick()
{
ThreadPool.QueueUserWorkItem(_ =>
{
list.Add(adder++);
});
}
2021-09-01 20:39:43 +09:00
}