Skip to content

Commit

Permalink
Merge all changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dwcullop committed Dec 22, 2023
2 parents 21c1ca6 + dec21ef commit 8321076
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/DynamicData/Cache/Internal/MergeManyCacheChangeSets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public IObservable<IChangeSet<TDestination, TDestinationKey>> Run() => Observabl

// When a source item is removed, all of its sub-items need to be removed
var removedItems = shared
.OnItemRemoved(mc => changeTracker.RemoveItems(mc.Cache.KeyValues, observer))
.OnItemRemoved(mc => changeTracker.RemoveItems(mc.Cache.KeyValues, observer), invokeOnUnsubscribe: false)
.OnItemUpdated((_, prev) => changeTracker.RemoveItems(prev.Cache.KeyValues, observer))
.Subscribe();

Expand Down
6 changes: 2 additions & 4 deletions src/DynamicData/List/Internal/MergeManyCacheChangeSets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,10 @@ public IObservable<IChangeSet<TDestination, TDestinationKey>> Run() =>
var changeTracker = new ChangeSetMergeTracker<TDestination, TDestinationKey>(() => sourceListOfCaches.Items.ToArray(), comparer, equalityComparer);

// Share a connection to the source list
var shared = sourceListOfCaches.Connect().Publish();
var shared = sourceListOfCaches.Connect().Synchronize(locker).Publish();

// Merge the child changeset changes together and apply to the tracker
var allChanges = shared
.Synchronize(locker)
.MergeMany(mc => mc.Source)
.Subscribe(
changes => changeTracker.ProcessChangeSet(changes, observer),
Expand All @@ -44,8 +43,7 @@ public IObservable<IChangeSet<TDestination, TDestinationKey>> Run() =>

// When a source item is removed, all of its sub-items need to be removed
var removedItems = shared
.Synchronize(locker)
.OnItemRemoved(mc => changeTracker.RemoveItems(mc.Cache.KeyValues, observer))
.OnItemRemoved(mc => changeTracker.RemoveItems(mc.Cache.KeyValues, observer), invokeOnUnsubscribe: false)
.Subscribe();

return new CompositeDisposable(sourceListOfCaches, allChanges, removedItems, shared.Connect());
Expand Down

0 comments on commit 8321076

Please sign in to comment.