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
[Experimental] Add SwiftUI.Binding support #256
[Experimental] Add SwiftUI.Binding support #256
Conversation
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.
Thank you for your contibutions.
Since the current Verge's SwiftUI support is not enough, your contributions and help would be a big support.
/// - mutation: A closure to update the state. | ||
/// If the closure is nil, state will be automatically updated. | ||
/// - Returns: The result of binding | ||
public func binding<T>(_ keypath: WritableKeyPath<State, T>, with mutation: ((T) -> Void)? = nil) -> Binding<T> { |
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 would be better to add the same method in StoreComponentType which just calls directly StoreType's one.
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.
or if you don't use StoreComponentType, we don't need to do this.
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.
✅ 6a55ea3
Thank you for the review and the approval! |
Motivation and Context
Most views that simply receive the state and reflect it in its appearance only need to get the state through a StateReader.
However, some views that update their state, such as a TextField, need to generate a SwiftUI.Binding.
I want to hide the generation process.
Description
StoreType provides a function that returns the instance of SwiftUI.Binding.