mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-14 07:33:28 +01:00
ListObjectObserver callbacks are not triggered after transaction.deleteAll
#380
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @oligazar on GitHub (Nov 6, 2021).
After using
transaction.deleteAllinsideasynchronousI don't get anyListObjectObserverevents anymore.So in the following code snippet after fetching any new page from API I add new items to the db. But once I need to restart pagination from the page 1, I want to remove all the outdated data (it's controlled by
forceRefreshflag). This operation seems to run successfully, meaning I do getlistMonitorDidChangecallback invocation, which I'm interested in. But all the subsequent inserts with new pages data don't trigger anyListObjectObservercallbacks anymore.I need some hint to figure out what can cause the issue because so far I'm very frustrated by it.
Thanks a lot!
@JohnEstropia commented on GitHub (Nov 8, 2021):
@oligazar I don't see anything that stands out from the snippet you posted, but some ideas that come to mind:
Whereclause used by theListMonitorListObjectObserveris still subscribed to changes (removeObserver(_:)is not called anywhere in between)ListMonitoris still retained in the first place@oligazar commented on GitHub (Nov 8, 2021):
@JohnEstropia thanks for your reply!
ListMonitoris still retained, and its observer as well. I compared hashValues before and after.Whereclause seems to be the same (it's not mine code so there's possibility that I'm missing something)removeObserver(_:)on it. But I think it's the most probable issue among others.Maybe there's a way to check whether
monitoris still holding a reference to observer? Or something different to check?@JohnEstropia commented on GitHub (Nov 8, 2021):
Yes, but what I mean was, are the new objects that are inserted afterwards still satisfying this predicate?
To clarify, the
ListMonitoronly keeps weak references to its observers. So don't expect it to retain the observer for you.Otherwise, there must be something else going on that breaks the notification chain. You can test the CoreStore demo app (example titled
Classic Colors Demo) where objects can be deleted at once and still continue to receive succeeding updates.@oligazar commented on GitHub (Nov 8, 2021):
Yes, new objects are still satisfying the predicate
So reinstantiating the monitor should resolve the issue, I guess?
I believe the demo app works as expected. The issue is most likely in my code. I just struggle to figure it out for a few days now.