mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-14 07:33:28 +01:00
ListPublisher callback is called too often and ObjectPublisher callback is never called #327
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 @joeljfischer on GitHub (Apr 13, 2020).
I'm having a very strange issue that I'm sure is user error, but that I haven't been able to solve.
ListPublishers being called too often
I have a table view class that is using a
ListPublisherand a cell class that's attempting to use aObjectPublisherto update itself when the object updates. I thought that theListPublisherwould only be called when the list itself experienced an insert, removal, or change in position, but it seems to be being called whenever a property on any data model it's managing is updated.This is being called whenever properties on any data updates and refreshes the list.
Object Publishers not being called
I also noticed that an object publisher was never calling it's updater when a property updated on the object.
This is called from the
datadidSet. However, the observer code is never called, even whendata's properties update.@skytoup commented on GitHub (Apr 14, 2020):
About
Object Publishers not being calledToday I ran into the same problem as you, after some debugging, I found a snapshot in ObjectPublisher:225 that was lazy loading, and only started monitoring the data changes at initialization.
so....
@joeljfischer commented on GitHub (Apr 14, 2020):
@skytoup Interesting, thanks for pointing that out! Perhaps removing the lazy load will fix the issue. If the first part of my issue is resolved this will be helpful. I changed to use
ObjectMonitorin a few places, which is working well for me for now.@JohnEstropia commented on GitHub (Apr 15, 2020):
Thanks for the input on this. It is true that the publisher observation starts on first access of
snapshot.Nonetheless, once you have the publisher instance, there is very little reason to use the
CoreStoreObjectinstance, so this is a bit of an antipattern:This would have been written as
Another thing I am wondering is where do you get
data? If you are planning to useObjectPublishers I recommend to reserveCoreStoreObjectaccess entirely for background updates.All that said, the lazy initialization of observers should be triggered from
addObserveras well, so I'll make a fix on the next update.