Closed MikeGarcia closed 8 years ago
Glad you are enjoying the library! The nice part about the fact that you have to log the notifications when using RBQFRC is that you have full control over what gets logged. This means that you can log both the parent and the child as being add/updated so that whatever RBQFRC is listening can respond to them. I would check out RBQRealmNotificationManager because in the end the category methods are just wrapping the Realm action together with one of the actual logger methods. You can always skip the category methods and just call the logger directly after performing the Realm change (but before you call commitWriteTransaction
).
To register that the parent and the child follow this pattern
[[RLMRealm defaultRealm] beginWriteTransaction];
...
// Create the child object, then use the convenience category method
// to perform the addition and log the change
[[RLMRealm defaultRealm] addOrUpdateObjectWithNotification:Child];
// Use the actual logger method to just mark the Parent as changed
[[RBQRealmChangeLogger defaultLogger] didChangeObject:Parent];
...
[[RLMRealm defaultRealm] commitWriteTransaction];
Perfect, I appreciate the direction, this is exactly what I needed, thanks Adam!
Firstly, thanks for providing this solution, it enabled me to finally make the switch over to realm, and so far the transition has been night and day as far as performance and complexity (reduction) is concerned. I've been trying to find the best way to notify my TableViewController which contains an RBQFetchedResultsController. The issue I am having is with tracking changes to my one-to-many relationship.
For example:
I have a thread that keeps our data in sync with our backend and as such I use a typical import:
Whenever I am in the TableView that fetches ClassB object(s) its never notified of any changes, this is particularly due to the fact that I am not using the notification methods within RLMRealm+Notifications.h.
I've tried various ways of adding ClassB objects using [realm addOrUpdateObjectWithNotification:...]; and then attempting to add it to ClassA, but this results in a throw.
Currently, the setup I have uses a RLMNotificationToken which causes my fetchedResultsController to update, whenever there is a didChangeNotification, this isn't ideal as any changes to the realm which may not particularly correlate to ClassA.children are invoked and cause the fetchResultsController to inefficiently refetch data. I understand that this is a current limitation because of the lacking fine grain notifications from realm, and I do understand that I can roll my own notifications. Is there something that I am missing in how I am importing my one-to-many relationship to benefit from notifications, without using my current setup?