Skip to content
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

Merged
merged 3 commits into from
Jul 25, 2020
Merged

Implement DynamicProperty #213

merged 3 commits into from
Jul 25, 2020

Conversation

carson-katri
Copy link
Member

@carson-katri carson-katri commented Jul 25, 2020

This matches the SwiftUI protocol DynamicProperty. I also modified State to use OpenCombine, let me know if you want that changed back. I also fixed an issue with environment injection in the process.

@carson-katri carson-katri added SwiftUI compatibility Tokamak API differences with SwiftUI bug Something isn't working labels Jul 25, 2020
@carson-katri carson-katri requested review from MaxDesiatov and j-f1 July 25, 2020 13:16
@@ -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]()
Copy link
Collaborator

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.

Copy link
Member Author

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.

Comment on lines 47 to 52
return .init {
// swiftlint:disable:next force_cast
_location.value as! Value
} set: {
_location.value = $0
}
Copy link
Collaborator

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.

Copy link
Collaborator

@MaxDesiatov MaxDesiatov left a 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.

@carson-katri carson-katri requested a review from MaxDesiatov July 25, 2020 16:06
Copy link
Collaborator

@MaxDesiatov MaxDesiatov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thank you 👍

@carson-katri carson-katri merged commit c68c70a into main Jul 25, 2020
@carson-katri carson-katri deleted the dynamicproperty branch July 25, 2020 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working SwiftUI compatibility Tokamak API differences with SwiftUI
Development

Successfully merging this pull request may close these issues.

3 participants