-
Notifications
You must be signed in to change notification settings - Fork 75
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
Making AnyItemModel implement ErasedContentProviding. #156
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ public protocol ErasedContentProviding { | |
/// A closure that can be called to determine whether the given `model`'s `erasedContent` is equal | ||
/// to this model's `erasedContent`, else `nil` if there is no content or the content is always | ||
/// equal. | ||
var isErasedContentEqual: ((Self) -> Bool)? { get } | ||
var isErasedContentEqual: ((ErasedContentProviding) -> Bool)? { get } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a very subtle change that could affect implementations, since now we don't guarantee at compile-time that the types we are comparing match. It would be nice if we did a search for how we are using this property internally to validate that we think this change is safe. |
||
} | ||
|
||
// MARK: - EpoxyModeled | ||
|
@@ -32,18 +32,18 @@ extension EpoxyModeled where Self: ErasedContentProviding { | |
/// A closure that can be called to determine whether the given `model`'s `erasedContent` is equal | ||
/// to this model's `erasedContent`, else `nil` if there is no content or the content is always | ||
/// equal. | ||
public var isErasedContentEqual: ((Self) -> Bool)? { | ||
public var isErasedContentEqual: ((ErasedContentProviding) -> Bool)? { | ||
get { self[isContentEqualProperty] } | ||
set { self[isContentEqualProperty] = newValue } | ||
} | ||
|
||
// MARK: Private | ||
|
||
private var contentProperty: EpoxyModelProperty<Any?> { | ||
.init(keyPath: \Self.erasedContent, defaultValue: nil, updateStrategy: .replace) | ||
.init(keyPath: \ErasedContentProviding.erasedContent, defaultValue: nil, updateStrategy: .replace) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wondered if changing the keys could break existing code. I see that |
||
} | ||
|
||
private var isContentEqualProperty: EpoxyModelProperty<((Self) -> Bool)?> { | ||
.init(keyPath: \Self.isErasedContentEqual, defaultValue: nil, updateStrategy: .replace) | ||
private var isContentEqualProperty: EpoxyModelProperty<((ErasedContentProviding) -> Bool)?> { | ||
.init(keyPath: \ErasedContentProviding.isErasedContentEqual, defaultValue: nil, updateStrategy: .replace) | ||
} | ||
} |
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.
@thedrick I see that you added this file. Do you have any thoughts on this change?
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.
@bachand no comments, it's entirely possible that this file used to be something totally different and the header was never updated. Eric is the one who wrote all of this code
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.
Thanks Tyler.