Permalink
Browse files

Getting rid of awkward reset overload

ReactiveDerivedCollection needs to override the implementation of Reset
while still being able to use SuppressChangeNotification. My previous
hack to allow this needs to be killed with fire so I'm adding
publishResetNotification to ReactiveCollection. It's not ideal but at
least it's better than the previous version.
  • Loading branch information...
niik authored and paulcbetts committed Mar 31, 2013
1 parent c46236c commit 08faf15c75dbe94435bb1da4ac35ee01c1c75e9a
Showing with 7 additions and 6 deletions.
  1. +7 −6 ReactiveUI/ReactiveCollection.cs
@@ -282,27 +282,28 @@ public virtual void RemoveAll(IEnumerable<T> items)
public virtual void Sort(int index, int count, IComparer<T> comparer)
{
_inner.Sort(index, count, comparer);
- Reset(true);
+ Reset();
}
public virtual void Sort(Comparison<T> comparison)
{
_inner.Sort(comparison);
- Reset(true);
+ Reset();
}
public virtual void Sort(IComparer<T> comparer = null)
{
_inner.Sort(comparer ?? Comparer<T>.Default);
- Reset(true);
+ Reset();
}
public virtual void Reset()
{
- Reset(true);
+ publishResetNotification();
}
- protected virtual void Reset(bool resetting)
+
+ protected virtual void publishResetNotification()
{
var ea = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset);
_changing.OnNext(ea);
@@ -349,7 +350,7 @@ public IDisposable SuppressChangeNotifications()
return Disposable.Create(() => {
if (Interlocked.Decrement(ref _suppressionRefCount) == 0) {
- Reset(true);
+ publishResetNotification();
}
});
}

0 comments on commit 08faf15

Please sign in to comment.