Created
October 21, 2020 07:28
-
-
Save RolandPheasant/d7a9680a959b483e7c3943b703d99bd9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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