Last active
February 9, 2021 17:00
-
-
Save rdelrosario/4498853136e5d3de2e58866a40c61430 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
public class ObservableGroupedCollection<TGroupKey, TObject, TKey> : ObservableCollectionExtended<TObject>, IDisposable | |
{ | |
public TGroupKey Key { get; } | |
public ObservableGroupedCollection(IGroup<TObject, TKey, TGroupKey> group, IObservable<Func<TObject, bool>> filter, IObservable<IComparer<TObject>> comparer) | |
{ | |
this.Key = group.Key; | |
//load and sort the grouped list | |
var dataLoader = group.Cache.Connect() | |
.Filter(filter) | |
.Sort(comparer) | |
.ObserveOn(RxApp.MainThreadScheduler) | |
.Bind(this) //make the reset threshold large because xamarin is slow when reset is called (or at least I think it is @erlend, please enlighten me ) | |
.Subscribe(); | |
_cleanUp = new CompositeDisposable(dataLoader); | |
} | |
public void Dispose() | |
{ | |
_cleanUp.Dispose(); | |
} | |
private readonly IDisposable _cleanUp; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment