Skip to content

Commit

Permalink
Getting rid of awkward reset overload
Browse files Browse the repository at this point in the history
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 anaisbetts committed Apr 1, 2013
1 parent c46236c commit 08faf15
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions ReactiveUI/ReactiveCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -349,7 +350,7 @@ public IDisposable SuppressChangeNotifications()

return Disposable.Create(() => {
if (Interlocked.Decrement(ref _suppressionRefCount) == 0) {
Reset(true);
publishResetNotification();
}
});
}
Expand Down

0 comments on commit 08faf15

Please sign in to comment.