-
-
Notifications
You must be signed in to change notification settings - Fork 112
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
Implement DynamicProperty
#213
Conversation
@@ -30,7 +30,7 @@ class MountedCompositeElement<R: Renderer>: MountedElement<R>, Hashable { | |||
var mountedChildren = [MountedElement<R>]() | |||
let parentTarget: R.TargetType | |||
|
|||
var state = [Any]() | |||
var state = [StateLocation]() |
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'm a bit unsure about the overhead of the new StateLocation
type. While previously the value was stored directly (boxed as Any
though), now there's an associated CurrentValueSubject
object, so at least from the memory perspective I wonder if it consumes a few more bytes per state object (at least in theory). In terms of performance I'm not able to say anything until we have a proper benchmark suite. And we totally should have benchmarks sooner rather than later, I'm chipping away small bits slowly in that direction to have a proper test suite first.
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.
Makes sense, I'll revert it.
return .init { | ||
// swiftlint:disable:next force_cast | ||
_location.value as! Value | ||
} set: { | ||
_location.value = $0 | ||
} |
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 hope we could avoid the multiple trailing closure syntax in cases such as this, where closures are symmetrical, but their labels no longer are.
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 is good stuff, modulo the StateLocation
memory/performance and multiple trailing closures comments.
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.
Awesome, thank you 👍
This matches the SwiftUI protocol
DynamicProperty
. I also modifiedState
to use OpenCombine, let me know if you want that changed back. I also fixed an issue with environment injection in the process.