Skip to content

Instantly share code, notes, and snippets.

@RolandPheasant
Created October 21, 2020 07:28
Show Gist options
  • Save RolandPheasant/d7a9680a959b483e7c3943b703d99bd9 to your computer and use it in GitHub Desktop.
Save RolandPheasant/d7a9680a959b483e7c3943b703d99bd9 to your computer and use it in GitHub Desktop.
var initialItems = Enumerable.Range(1, 5_000)
.Select(i => new SelectableItem(i){IsSelected = true})
.ToArray();
var source = new SourceList<SelectableItem>();
var filtered = source.Connect()
.AutoRefresh(si=>si.IsSelected)
.Filter(si => si.IsSelected)
.Subscribe(_=> Console.WriteLine("got initial data"));
var sw = Stopwatch.StartNew();
source.AddRange(initialItems);
sw.Stop();
Console.WriteLine(sw.ElapsedMilliseconds);
--------------------------------------------------
public class SelectableItem : AbstractNotifyPropertyChanged
{
public int Id { get; }
public SelectableItem(int id)
{
Id = id;
}
private bool _isSelected;
public bool IsSelected
{
get => _isSelected;
set => SetAndRaise(ref _isSelected, value);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment