My project has CoreData database with 1 root context and multiple sub contexts.
I have a ViewModel that contains an Item (NSManagedObject). When I changes something in an Item the persistence is made in the root context and then automatically merged into all sub-contexts.
I want to replace the NSFetchedResultsController with ReactiveSwift Signals / Properties, to observe changes in the item object.
ViewModel:
var itemProperty: MutableProperty<Item> = MutableProperty(contextItem)
ViewController:
self.viewModel.itemProperty.signal.observeValues{ (item: Item) in
let newName = item.name
print("name: \(newName!)"
}
After I change the item's name somewhere else, the changes are propagated to the ViewModel sub-context (the NSFetchedResultsController gets notified), BUT the signal never pushes a new item event.
Maybe because the NSManagedObject reference never changes? I know I can observe changes to specific properties in an object with producer(forKeyPath: "propertyKeyPath" ), but I don't want to observe just one specific property of the item, I want to observe ALL changes.
Is there a way to observe ANY change in all the object's properties ??