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
Move binding warning suppression to dynamic member lookup #2740
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In TCA it is considered a bug to send an action to a child feature when it is dismissed. In SwiftUI, a focused text field binding will write to itself when the view it is presented in is dismissed. So if you derive a TCA binding to a text field in a dismissable child feature, dismissing said feature will write to the text field and cause a warning to be emitted. To work around this, we set a task local, and are currently setting it in debug-only methods that construct a binding from scratch. Creating bindings from scratch unfortunately leads to issues with animations, so we should avoid doing so. Instead, we can leverage properties on store that bindings are derived from and suppress the warnings from there.
stephencelis
commented
Jan 30, 2024
} | ||
@available(iOS 17, macOS 14, tvOS 17, watchOS 10, *) | ||
@dynamicMemberLookup | ||
public struct _StoreBindable_SwiftUI<State: ObservableState, Action, Value> { |
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.
While I think it might be possible to abstract these 3 "store binding" types, I'm not sure it's worth it or a good idea.
mbrandonw
approved these changes
Jan 30, 2024
cgrindel-self-hosted-renovate bot
added a commit
to cgrindel/rules_swift_package_manager
that referenced
this pull request
Jan 31, 2024
…ure to from: "1.7.1" (#887) This PR contains the following updates: | Package | Update | Change | |---|---|---| | [pointfreeco/swift-composable-architecture](https://togithub.com/pointfreeco/swift-composable-architecture) | patch | `from: "1.7.0"` -> `from: "1.7.1"` | --- ### Release Notes <details> <summary>pointfreeco/swift-composable-architecture (pointfreeco/swift-composable-architecture)</summary> ### [`v1.7.1`](https://togithub.com/pointfreeco/swift-composable-architecture/releases/tag/1.7.1) [Compare Source](https://togithub.com/pointfreeco/swift-composable-architecture/compare/1.7.0...1.7.1) #### What's Changed - Fixed: The Composable Architecture's SwiftUI Binding helpers should better preserve SwiftUI animation and transaction information ([pointfreeco/swift-composable-architecture#2740). Previously, animations could be lost in certain situations. - Fixed: `@ObservableState` now supports the `package` access modifier (thanks [@​nnsnodnb](https://togithub.com/nnsnodnb), [pointfreeco/swift-composable-architecture#2741). - Deprecated: `Reducer.onChange(of:removeDuplicates:)` has been deprecated ([pointfreeco/swift-composable-architecture#2744). The `removeDuplicates` argument put strain on the compiler that could cause reducers to not compile in time. Migration strategy: use an explicit wrapper type that is `Equatable`, instead. - Infrastructure: Migrating to 1.7 fixes (thanks [@​acosmicflamingo](https://togithub.com/acosmicflamingo), [pointfreeco/swift-composable-architecture#2732; thanks [@​bricklife](https://togithub.com/bricklife), [pointfreeco/swift-composable-architecture#2736; thanks [@​zvona031](https://togithub.com/zvona031), [pointfreeco/swift-composable-architecture#2738; thanks [@​shgew](https://togithub.com/shgew); [pointfreeco/swift-composable-architecture#2743); README fix (thanks [@​yimajo](https://togithub.com/yimajo), [pointfreeco/swift-composable-architecture#2734). #### New Contributors - [@​acosmicflamingo](https://togithub.com/acosmicflamingo) made their first contribution in [pointfreeco/swift-composable-architecture#2732 - [@​zvona031](https://togithub.com/zvona031) made their first contribution in [pointfreeco/swift-composable-architecture#2738 - [@​shgew](https://togithub.com/shgew) made their first contribution in [pointfreeco/swift-composable-architecture#2743 - [@​nnsnodnb](https://togithub.com/nnsnodnb) made their first contribution in [pointfreeco/swift-composable-architecture#2741 **Full Changelog**: pointfreeco/swift-composable-architecture@1.7.0...1.7.1 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://togithub.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://togithub.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi4xMDAuMCIsInVwZGF0ZWRJblZlciI6IjM2LjEwMC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> Co-authored-by: Self-hosted Renovate Bot <361546+cgrindel-self-hosted-renovate[bot]@users.noreply.github.enterprise.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In TCA it is considered a bug to send an action to a child feature when it is dismissed.
In SwiftUI, a focused text field binding will write to itself when the view it is presented in is dismissed.
So if you derive a TCA binding to a text field in a dismissable child feature, dismissing said feature will write to the text field and cause a warning to be emitted.
To work around this, we set a task local, and are currently setting it in debug-only methods that construct a binding from scratch. Creating bindings from scratch unfortunately leads to issues with animations, so we should avoid doing so.
Instead, we can leverage properties on store that bindings are derived from and suppress the warnings from there.