You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 3, 2020. It is now read-only.
This is a follow-up issue for #48 for discussions and actual implementation of automatic removal of any observation registered via KVOController when the observed objects are not retained in any way.
The story here is that unless you let KVOController retain the objects - all of the observation becomes as fragile as it is with vanilla Cocoa KVO APIs.
Taking into account that we all would love to observe things in a "weak" way - there are 2 ways one could implement such a thing:
Swizzle dealloc and unregister registered observers or KVOControllers there. Sounds like less than ideal solution, but this will work just as fine. It feels very very fragile, but is a supported use case for ObjC runtime.
Use a separate instance of a custom class to box the original object into a property and store all of the observation info inside of it instead of a custom map table inside KVOController. As well as add all of the KVO observation with extra prefix path component whenever KVOController is registering an observer. Then store this instance via associated objects on the observed object.
This will allow both weak reference to the original object, as well as to know the moment where we need to unregister KVO, as associated objects are cleaned up automatically on dealloc.
Do you have an idea/suggestion/comment? Great! Please post it here!
Do you want to take a chance on implementing this? Amazing! Pull requests are very very welcome, and I'll do my best to review/guide/help/drive any implementation of this.