I want to achieve the following: Whenever someone triggers a CoreData save (ie. NSManagedObjectContextDidSave
notification gets sent), I\'d like to perform some
You can pass the object you want to observe to publisher(for:)
:
NotificationCenter.default
.publisher(for: .NSManagedObjectContextDidSave, object: backgroundMoc)
.sink(receiveValue: { notification in
// handle changes
})
That will only listen for notifications related to a background managed object context which means you can do processing on that context's queue safely.