-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DelegateProxy revamp #3467
base: master
Are you sure you want to change the base?
DelegateProxy revamp #3467
Conversation
44f9f14
to
22d03c7
Compare
b18dff1
to
2646832
Compare
3305254
to
b13fc84
Compare
35c2820
to
8eb671d
Compare
@mdiep any chance of moving this forward? |
Somehow I missed this. I just got back from vacation, but I'll this to my list. Want to fix up the conflicts, @andersio? |
Sure. Will do it this week. |
ReactiveCocoa/DelegateProxy.swift
Outdated
private final let originalSetter: (AnyObject) -> Void | ||
private final let objcProtocol: Protocol | ||
|
||
public required init(config: DelegateProxyConfiguration) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be public
? Or should we only expose the proxy
method below?
If this is public
, should we inline the properties from DelegateProxyConfiguration
in the init
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The initialiser is meant to be exposed, while the details of the configuration are meant to be hidden. This is to satisfy the compiler constraint of instantiating instances from the metatype of the non-final DelegateProxy
, which requires init(DelegateProxyConfiguration)
to be always present in all subclasses, so that the instantiation via the metatype always succeeds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is DelegateProxy
non-final?
CI build might be affected by #3642. |
ReactiveCocoa/DelegateProxy.swift
Outdated
fileprivate let originalSetter: (AnyObject) -> Void | ||
} | ||
|
||
public class DelegateProxy<Delegate: NSObjectProtocol>: NSObject, DelegateProxyProtocol { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't DelegateProxy
be final
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But if you still think it is more sensible for us to start with final
, I am fine with that.
Apparently I've already made it non-open. I guess the intention of not marking it as final
is to avoid any library evolution implication — undoing final
is not a permitted change.
Most importantly, this entity primarily interacts with ObjC which final
has no effect, and being public
already prohibits subclassing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But if we made it final
, then we could make this method private? That seems worth doing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In any case I think intercepting non-void returning methods is probably very niche, and a rather dangerous zone to walk into with little return. So closing it should be fine.
Let's get this merged before doing a new release for ReactiveSwift 5. The only outstanding question from me is this. If we can't do that, you're good to merge. |
The tests need to be updated to not inherit from |
@andersio I'd like to release ReactiveCocoa 9.0. Still want to get this in? |
It looks like there may still be some legitimate test failures? |
Methods would now be automatically implemented. Subclassing is no longer necessary.
DelegateProxy
can now be constructed throughNSObject.reactive.proxy(forKey:)
.Fixed a memory leak due to the use of
forwardingTarget(for:)
as the fast path of delegate call forwarding.More
DelegateProxy
test cases.Usage
To-do