-
Notifications
You must be signed in to change notification settings - Fork 210
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
@propertyWrapper Published #52
Conversation
LGTM Generated by 🚫 Danger Swift against a2903f0 |
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.
Thank you!
I've added some comments, but in order for it to be merged we'll need tests, also can you please address the bot's comments? :)
Sorry for inconvenience. It is first time when I do pull request to GitHub. I fixed all comments and also warnings from SwiftLint. It remains only to write tests. |
I’m flattered!
When you write the tests, commit them to this branch, it is better if they come along with the feature that they test. No need to create a separate pull request for that :) |
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.
Can you please remove the interface of Published
from the RemainingCombineInterface.swift so that we can track what's implemented and what's not?
I also see that your implementation lacks this subscript. Implementing it is non-trivial, so I suggest to add a stub marked as unavailable:
@available(*, unavailable, message: "This subscript is unavailable in OpenCombine yet")
public static subscript<EnclosingSelf: AnyObject>(
_enclosingInstance object: EnclosingSelf,
wrapped wrappedKeyPath: ReferenceWritableKeyPath<EnclosingSelf, Value>,
storage storageKeyPath: ReferenceWritableKeyPath<EnclosingSelf, Published<Value>>
) -> Value {
get { fatalError() }
set { fatalError() }
}
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.
I also see that your implementation lacks this subscript. Implementing it is non-trivial, so I suggest to add a stub marked as unavailable:
@available(*, unavailable, message: "This subscript is unavailable in OpenCombine yet") public static subscript<EnclosingSelf: AnyObject>( _enclosingInstance object: EnclosingSelf, wrapped wrappedKeyPath: ReferenceWritableKeyPath<EnclosingSelf, Value>, storage storageKeyPath: ReferenceWritableKeyPath<EnclosingSelf, Published<Value>> ) -> Value { get { fatalError() } set { fatalError() } }
I've added this subscript, but I didn't find that implementation in Apple Combine framework (Xcode 11.0 beta 6). I will be grateful If you give me more information about that functionality and how I can use that. Thanks!
Codecov Report
@@ Coverage Diff @@
## master #52 +/- ##
==========================================
+ Coverage 97.55% 97.74% +0.18%
==========================================
Files 42 43 +1
Lines 1679 1727 +48
==========================================
+ Hits 1638 1688 +50
+ Misses 41 39 -2
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #52 +/- ##
==========================================
+ Coverage 97.55% 97.74% +0.18%
==========================================
Files 42 43 +1
Lines 1679 1727 +48
==========================================
+ Hits 1638 1688 +50
+ Misses 41 39 -2
Continue to review full report at Codecov.
|
@beastgrim sure. This is used for accessing the object that has its property wrapped in You may wonder why I said it's non-trivial. The answer is that you will somehow need to provide a default implementation for the |
Thanks! This looks good to me. Are you up to write some tests? I could write them myself if you don’t feel like it. We also have our CI failing, but that’s not your fault, it just needs to be updated for the newest Swift version. |
I can write tests for Published but before I would like complete all in Published functionality. There is one property that doesn't exist now "objectWillChange"
So I'm going make some investigation how and when this "objectWillChange" uses in Combine framework and after that finish code in "Published" struct. And then cover all code with tests. I also do not mind if you confirm this pull request. And I will make all these things in another pull request. As it suits you best. |
I’ve already investigated it and have a prototype implementation :) This But if you’d really like to try to make it, you can take a look at this library and this doc on type metadata. |
I could not come up with tests for "Published", this is more like a template for tests. Sorry 😐 |
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.
So I've just merged #54, can I ask you to synchronize with the master branch?
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.
Thank you for your contribution, @beastgrim!
Hello! I've implemented this interface. That allows use construction like this:
@Published var value: String?
And bind and subscribe:
$value.assign(to: \.text, on: textLabel)
I hope that will be helpful.