-
Notifications
You must be signed in to change notification settings - Fork 11
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
Reusability hint to improve reuse performance when composite components are present. #146
base: develop
Are you sure you want to change the base?
Conversation
0e8a437
to
7916f46
Compare
7916f46
to
86da5eb
Compare
Bento/Renderable/Renderable.swift
Outdated
} | ||
|
||
public extension Renderable { | ||
func makeReusabilityHint(using combiner: inout ReusabilityHintCombiner) {} |
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.
Does it scan it through the hierarchy? e.g C(children: [C(children: [A()], B()])
vs C(children: [C(children: [B()], A()])?
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.
It doesn’t do so automatically. When you say combiner.combine(child)
, A’s part of the call it would eventually invoke makeReusabilityHint(using:)
on the child. So as long as you combine every child using the combiner, and that all descendants implement this, the whole hierarchy would be walked over.
This can be made less crumblesome if we have a protocol for composite component e.g. CompositeRenderable
which is also useful for auto propagation of messages like *LifecycleAware
. But this can be done after this PR which lays the cornerstone.
Bento/Views/BentoReusableView.swift
Outdated
if let view = containedView, type(of: view) == component.viewType { | ||
if let oldComponent = oldComponent, | ||
let view = containedView, | ||
oldComponent.reusabilityHintCombiner.isCompatible(with: component.reusabilityHintCombiner) { |
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.
This should not usually happen, should it?
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.
All visible items hit this path when the state changes.
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 mean oldComponent.reusabilityHintCombiner.isCompatible(with: component.reusabilityHintCombiner)
to be false
. As it'f false it means that we are recreating the view, right?
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.
yeh
I actually realise when answering Sergey’s questions about walking the hierarchy, that we need to generate the reuse identifier with not only That’s also reiterate the value of closing off custom |
4a72210
to
73f6360
Compare
Need to think about how this should integrate with #162. |
The purpose of this change is pretty much summed up in the documentation for
Renderable.makeReusabilityHint(using:)
.The design is inspired by how
Hashable
handles nested hashing.Do also note that implementing
makeReusabilityHint(using:)
does not imply that a composite component no longer needs to handle type mismatch in view hierarchy.