8000 [POC] Reconsider associatedProperty(), associatedObject(), rex_valueProperty() interfaces by ikesyo · Pull Request #69 · RACCommunity/Rex · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[POC] Reconsider associatedProperty(), associatedObject(), rex_valueProperty() interfaces #69

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

Merged
merged 5 commits into from
Nov 25, 2015

Conversation

ikesyo
Copy link
Member
@ikesyo ikesyo commented Nov 25, 2015

This change enables to pass the host (receiver) instance to initial and setter closures. Thus the caller of the functions don't need to use weak-captured host instance to implement the closures.

NSObjectType protocol and rex_valueProperty() which is based on its InstanceType typealias might seem tricky. We can remove the trick if needed with the way as UIBarItem.rex_enabled is implemented (direct use of associatedProperty()).

…roperty() interfaces

This change enables to pass the host (receiver) instance to `initial` and `setter` closures. Thus the caller of the functions don't need to use weak-captured host instance to implement the closures.

`NSObjectType` protocol and `rex_valueProperty()` which is basend on its `InstanceType` typealias might seem tricky. We can remove the trick if needed with the way as `UIBarItem.rex_enabled` is implemented (direct use of `associatedProperty()`).
@neilpa
Copy link
Member
neilpa commented Nov 25, 2015

Awesome! I'm all for making it even easier and less error prone to expose additional properties.

@@ -55,10 +55,16 @@ public func associatedProperty<T: AnyObject>(host: AnyObject, keyPath: StaticStr
///
/// N.B. Ensure that `host` isn't strongly captured by `initial` or `setter`, otherwise this
/// will create a retain cycle with `host` causing it to never dealloc.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment and the ones like it below can all be removed now since you've isolated the problem and caller's don't need to worry about it.

@ikesyo
Copy link
Member Author
ikesyo commented Nov 25, 2015

This comment and the ones like it below can all be removed now since you've isolated the problem and caller's don't need to worry about it.

I leave the comment for placeholder: () -> T since Host is not passed to it. Should we just remove the comment or pass Host?

@neilpa
Copy link
Member
neilpa commented Nov 25, 2015

Lets leave that one as-is.

neilpa added a commit that referenced this pull request Nov 25, 2015
Reconsider associatedProperty(), associatedObject(), rex_valueProperty() interfaces
< 99D8 div class="TimelineItem js-details-container Details" id="event-474718379" >
@neilpa neilpa merged commit 9613324 into RACCommunity:master Nov 25, 2015
@neilpa
Copy link
Member
neilpa commented Nov 25, 2015

🎊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0