New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add change information to collection notifications #3359
Conversation
1536fd3
to
965545f
Compare
self.tableView.endUpdates() | ||
break | ||
case .Error(let err): | ||
// An error occured while opening the Realm file on the background worker thread |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed this when copying this code for the documentation: 'occurred' needs another 'r' there.
After thinking about it some more and looking at some code using the notifications, I'm now thinking that the obj-c NSIndexPath version should be Only generating paths for section 0 makes it not useful for grouped table views, and generalizing it doesn't really make it worse for the simple case. In Swift, you can just do |
I tried using fine-grained notifications for the GroupedTableView example, and it turns out that the current design doesn't work for that when a single transaction modifies multiple sections. The problem is that all of the sections need to be updated within a single UITableView batch as it rechecks the sizes of all of the groups when you call
|
NotificationToken& operator=(NotificationToken const&) = delete; | ||
|
||
private: | ||
util::AtomicSharedPtr<_impl::BackgroundCollection> m_query; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
m_query
doesn't seem like an appropriate name for this member given that the thing it holds is described as a collection.
This is done for all addNotificationBlock methods. The explanation points out that the token has to be retained and how to stop notifications. The former is also enforced via `@warn_unused_result`. So this is likely the least important information in the method description.
I love the newly-added comments explaining the move detection code! 👍 |
Thank you @tgoyne and the team! |
@@ -201,10 +197,28 @@ void RealmCoordinator::clear_cache() | |||
} | |||
} | |||
|
|||
void RealmCoordinator::clear_all_caches() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't appear to be used anywhere. Is it still worth keeping around?
This adds a third parameter to the notification block on Results/List/RLMResults/RLMArray/etc. that reports the indices in the collection which were deleted, inserted and modified. In addition, it skips sending the notification when the collection did not actually change, rather than notifying on every change to the relevant table(s). It does not include information about which property on the object at the given index changed or supply the old value at that index; for those KVO on each object must be used.
Most of the testing for this is done at the objectstore level, so see the corresponding PR there.
Closes #687. Closes #3435.
Things left to do:
Add an NSOutlineView exampleMy current goal performance-wise is to have everything be fast enough that no one will need a way to opt-out of the changeset calculations, as that'd make the API unpleasant. Since most of the work is done on background threads and doesn't block the UI this should be easily attainable.