RxDataSources
RxDataSources copied to clipboard
Updates in CoreData NSManagedObject subclasses are not detected.
Hey all, I'm fetching changes from CoreData with RxCoreData and displaying the in a UITableView with RxDataSources (4.0.1). Add and remove operations work great. But updates, changes to the content of a MSManagedObject subclass, are not triggering an update in the table view.
Looking in RxTableViewSectionedAnimatedDataSource I see that the oldSections and newSections arrays being passed to Differentiator are identical … so of course it can't spot any diffs.
The arrays are identical, I presume, because of the 'always up to date' behaviour of NSManagedObject subclasses.
Is there a simple way around this problem?
With some more thought, I guess there are two solutions;
- Accept the CoreData objects are mutable and self updating. Bind each cell's views to the NSManagedObject's properties directly. Then cells contents will update as the model object does and it doesn't matter that RxDataSources doesn't trigger the cell to update. Adds and Removes would still be handled by RxDataSources.
- Continue to pretend that CoreData objects are not mutable and self updating. Wrap the NSManagedObject subclass in a struct (or something) that also holds a static value (eg. a hash) computed from the values in the NSManagedObject at the moment of last signal from the Observable datasource. Then Differentiator will have something static to compute diffs from.
Anything I'm missing?