Updating one of objects from relationship set not triggers the objectMonitor's "didUpdateObject" method #335

Closed
opened 2025-12-29 15:29:20 +01:00 by adam · 2 comments
Owner

Originally created by @itShouldWork on GitHub (Jul 13, 2020).

I have an object:

class Dialog: CoreStoreObject {

@Field.Relationship("messages", inverse: \.$dialog, deleteRule: .cascade)
var messages: Set<Message>

}

On some events one or many messages in dialog can be changed (message’s text etc).
I need to handle these changes via «objectMonitor» that observes the «Dialog» object, but the «didUpdateObject» method doesn’t call. As I suppose, because the «Dialog» object really hasn’t changes (there are changes only for messages). However, if I could get a notification about the change of the «Dialog» object through the "didUpdateObject" method, that would be great.
Do you have any idea how I can get this behaviour?

Thank you in advance!

Originally created by @itShouldWork on GitHub (Jul 13, 2020). I have an object: `class Dialog: CoreStoreObject {` @Field.Relationship("messages", inverse: \.$dialog, deleteRule: .cascade) var messages: Set<Message> `}` On some events one or many messages in dialog can be changed (message’s text etc). I need to handle these changes via «**objectMonitor**» that observes the «**Dialog**» object, but the «**didUpdateObject**» method doesn’t call. As I suppose, because the «**Dialog**» object really hasn’t changes (there are changes only for messages). However, if I could get a notification about the change of the «**Dialog**» object through the "**didUpdateObject**" method, that would be great. Do you have any idea how I can get this behaviour? Thank you in advance!
adam added the question label 2025-12-29 15:29:20 +01:00
adam closed this issue 2025-12-29 15:29:21 +01:00
Author
Owner

@JohnEstropia commented on GitHub (Jul 16, 2020):

Relationship properties do not notify any of the observers. This is the behavior inherited from Core Data.
If you need this functionality, create a property in the parent object that gets updated whenever the child object is updated.
In your case for example, you could have a Dialog.updatedDate property that can be updated whenever a reload is needed.

@JohnEstropia commented on GitHub (Jul 16, 2020): Relationship properties do not notify any of the observers. This is the behavior inherited from Core Data. If you need this functionality, create a property in the parent object that gets updated whenever the child object is updated. In your case for example, you could have a `Dialog.updatedDate` property that can be updated whenever a reload is needed.
Author
Owner

@itShouldWork commented on GitHub (Jul 17, 2020):

Got it, thanks for the answer!

I would like to take this moment to express my deep gratitude for this framework!👏

@itShouldWork commented on GitHub (Jul 17, 2020): Got it, thanks for the answer! I would like to take this moment to express my deep gratitude for this framework!👏
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/CoreStore#335