-
Notifications
You must be signed in to change notification settings - Fork 48
Utilize cache infra #587
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
base: maxg/cache_2_envcache
Are you sure you want to change the base?
Utilize cache infra #587
Changes from all commits
3abebaf
9b87e2a
6802a22
6429e56
76aee10
44aa682
10d11e9
ee32e1c
23a1dee
dad612b
7c6b2dc
e46e778
5faf9e1
5ef770e
6dafc50
56b751d
4a126e7
499ee96
15d0c5d
0d413d3
94e9b23
1c45f7f
9afcdd1
42104f9
398dc40
22ed032
be9dd21
942c1fa
6519418
e8c27c0
872bcaa
afbbc3c
f5ea2eb
f4c5c2e
c2e2ddc
9c0da9f
1842de6
0f19b47
707cc8d
3ec654b
76cac01
ea63760
f35c210
a599c4a
993355b
094dbcd
33979ef
1f9b9be
c8ab1d0
7dc49fc
6e8ffbb
2d81d45
e989861
595c0bf
3344add
9ae20e1
67d3f19
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 | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -40,6 +40,8 @@ public final class BlueprintView: UIView { | |||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| private var sizesThatFit: [SizeConstraint: CGSize] = [:] | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| private var hostingViewContext = Environment.HostingViewContextKey.defaultValue | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| /// A base environment used when laying out and rendering the element tree. | ||||||||||||||||||||||||||||
| /// | ||||||||||||||||||||||||||||
| /// Some keys will be overridden with the traits from the view itself. Eg, `windowSize`, `safeAreaInsets`, etc. | ||||||||||||||||||||||||||||
|
|
@@ -52,6 +54,13 @@ public final class BlueprintView: UIView { | |||||||||||||||||||||||||||
| didSet { | ||||||||||||||||||||||||||||
| // Shortcut: If both environments were empty, nothing changed. | ||||||||||||||||||||||||||||
| if oldValue.isEmpty && environment.isEmpty { return } | ||||||||||||||||||||||||||||
| // Shortcut: If there are no changes to the environment, then, well, nothing changed. | ||||||||||||||||||||||||||||
| if let layoutMode, layoutMode.options.skipUnneededSetNeedsViewHierarchyUpdates && oldValue.isCacheablyEquivalent( | ||||||||||||||||||||||||||||
| to: environment, | ||||||||||||||||||||||||||||
| in: .all | ||||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| setNeedsViewHierarchyUpdate() | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
@@ -86,6 +95,13 @@ public final class BlueprintView: UIView { | |||||||||||||||||||||||||||
| if oldValue == nil && element == nil { | ||||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| if let layoutMode, layoutMode.options.skipUnneededSetNeedsViewHierarchyUpdates, let crossLayoutCacheable = element as? CrossLayoutCacheable, crossLayoutCacheable.isCacheablyEquivalent( | ||||||||||||||||||||||||||||
| to: oldValue as? CrossLayoutCacheable, | ||||||||||||||||||||||||||||
| in: .all | ||||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||||
|
Comment on lines
+98
to
+101
Collaborator
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. similar thing for layotuMode + a formatting suggestion to reduce line length
Suggested change
|
||||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| hostingViewContext = Environment.HostingViewContextKey.defaultValue | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| Logger.logElementAssigned(view: self) | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
@@ -148,6 +164,7 @@ public final class BlueprintView: UIView { | |||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| self.element = element | ||||||||||||||||||||||||||||
| self.environment = environment | ||||||||||||||||||||||||||||
| self.environment.hostingViewContext = hostingViewContext | ||||||||||||||||||||||||||||
|
Collaborator
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. resurrected from a resolved comment:
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| rootController = NativeViewController( | ||||||||||||||||||||||||||||
| node: NativeViewNode( | ||||||||||||||||||||||||||||
|
|
@@ -542,9 +559,13 @@ public final class BlueprintView: UIView { | |||||||||||||||||||||||||||
| environment.layoutMode = layoutMode | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| environment.hostingViewContext = hostingViewContext | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| return environment | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| private func handleAppeared() { | ||||||||||||||||||||||||||||
| rootController.traverse { node in | ||||||||||||||||||||||||||||
| node.onAppear?() | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
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.
adapting a previous comment into a suggestion: