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
Overload <~
to automatically bridge values to Objective-C
#2551
Conversation
While this is cool, I'm 👎 on adding it. Each additional operator overload almost always creates a significant negative impact to compile times. I've seen exponential or worse degradations per-overload on other projects. I also don't want to encourage further use of |
Are you referring to ReactiveCocoa compile times, or compile times for callers of the operator? |
Existing usage of the operator |
Although I'll admit that my data on compile-time increases when calling overloaded operators is anecdotal from twitter and other github issues. |
Thanks for the PR!
For sure, but we need to improve the current situation because right now it's really hard to use with I think this is interesting too, but it only solves a tiny portion of the problems. What I brought up in #2535 was a more general perspective of the issue, which how hard to compose |
So, for posterity at least, I've just pushed a commit that adds one more overload for binding a source Compile-time performance is really important, so I think it would be really interesting to measure the difference these overloads would make to a project that uses a lot of bindings. Validating our assumptions there could at least be data to back a radar about compile-time performance for overloaded operators. I don't feel like my current project is of a sufficient size to really validate the performance question (at least at its current early stage). Is there perhaps anyone we could invite to try out this branch and report back? |
Also, regarding the future design questions about composition of properties, is the hope to solve that for RAC 4 (in case breaking changes are required)? In my use, I'm finding that it adds a lot of value to my codebase in terms of readability, so I think it would be great to have some kind of enhancement available in 4.0. |
@neilpa @NachoSoto should this be merged or closed? |
|
||
/// Binds a signal producer to a `DynamicProperty`, automatically bridging values to Objective-C. | ||
public func <~ <Value: _ObjectiveCBridgeable>(property: DynamicProperty, producer: SignalProducer<Value, NoError>) -> Disposable { | ||
return property <~ producer.map { $0._bridgeToObjectiveC() } |
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 indentation here and above is off. RAC uses tabs.
I agree both that (a) the current situation is not great and (b) the type-unsafely of In light of that, I'd suggest:
What does everyone think of that? @sharplet, would you be interested in opening a PR for (2)? |
@mdiep I've fixed up the indentation and rebased on master. I took a stab at (2), and I'll be pushing a PR for it shortly! |
#2852 is merged for RAC 5 with breaking changes, but should this still be merged for current RAC 4? |
👍 to merging this. Let's get the CI build to pass though. |
Looks like the build passed on the last commit? |
If failed the first time, but I reran it. 😄 |
Excellent, thanks everyone! |
There seems to a good amount of evidence that doing this kind of thing is no fun:
I worked out a way to overload
<~
for types that are_ObjectiveCBridgeable
and automatically bridge them.I'm not sure how I feel about the use of
_ObjectiveCBridgeable
and_bridgeToObjectiveC()
. But I think this is pretty nice to have, and it should be equivalent to the implicitly bridged version.P.S.
I didn't include it in the PR, but I also add this function to my project which brings it back to RAC 2 levels of awesomeness: