Skip to content

Commit 3984234

Browse files
author
Paul Betts
committed
Merge pull request #678 from reactiveui/call_did_perform_updates_properly
Move didPerformUpdates in the collection view case into the completion handler
2 parents e8d97df + 068b9dd commit 3984234

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

ReactiveUI/Cocoa/CommonReactiveSource.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace ReactiveUI
2020
interface IUICollViewAdapter<TUIView, TUIViewCell>
2121
{
2222
void ReloadData();
23-
void PerformBatchUpdates(Action updates);
23+
void PerformBatchUpdates(Action updates, Action completion);
2424
void InsertItems(NSIndexPath[] paths);
2525
void DeleteItems(NSIndexPath[] paths);
2626
void ReloadItems(NSIndexPath[] paths);
@@ -377,7 +377,7 @@ void sectionCollectionChanged(int section, IList<Timestamped<NotifyCollectionCha
377377
break;
378378
}
379379
}
380-
380+
}, () => {
381381
this.Log().Debug("Ending update");
382382
didPerformUpdates.OnNext(eas);
383383
});

ReactiveUI/Cocoa/ReactiveCollectionViewSource.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class UICollectionViewAdapter : IUICollViewAdapter<UICollectionView, UICollectio
5151
internal UICollectionViewAdapter(UICollectionView view) { this.view = view; }
5252

5353
public void ReloadData() { view.ReloadData(); }
54-
public void PerformBatchUpdates(Action updates) { view.PerformBatchUpdates(new NSAction(updates), null); }
54+
public void PerformBatchUpdates(Action updates, Action completion) { view.PerformBatchUpdates(new NSAction(updates), (completed) => completion()); }
5555
public void InsertItems(NSIndexPath[] paths) { view.InsertItems(paths); }
5656
public void DeleteItems(NSIndexPath[] paths) { view.DeleteItems(paths); }
5757
public void ReloadItems(NSIndexPath[] paths) { view.ReloadItems(paths); }

ReactiveUI/Cocoa/ReactiveTableViewSource.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,15 @@ class UITableViewAdapter : IUICollViewAdapter<UITableView, UITableViewCell>
6262
readonly UITableView view;
6363
internal UITableViewAdapter(UITableView view) { this.view = view; }
6464
public void ReloadData() { view.ReloadData(); }
65-
public void PerformBatchUpdates(Action updates)
65+
public void PerformBatchUpdates(Action updates, Action completion)
6666
{
6767
view.BeginUpdates();
68-
try { updates(); }
69-
finally { view.EndUpdates(); }
68+
try {
69+
updates();
70+
} finally {
71+
view.EndUpdates();
72+
completion();
73+
}
7074
}
7175
public void InsertItems(NSIndexPath[] paths) { view.InsertRows(paths, UITableViewRowAnimation.Automatic); }
7276
public void DeleteItems(NSIndexPath[] paths) { view.DeleteRows(paths, UITableViewRowAnimation.Automatic); }

0 commit comments

Comments
 (0)