Skip to content

ViewStore.init(_:observe:) #1448

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

Merged
merged 3 commits into from
Oct 10, 2022
Merged

ViewStore.init(_:observe:) #1448

merged 3 commits into from
Oct 10, 2022

Conversation

mbrandonw
Copy link
Member

@mbrandonw mbrandonw commented Oct 6, 2022

A month ago we soft deprecated WithViewStore(_:) in favor of an explicit WithViewStore(_:observe:) that tries to make it more public that you are are observing data with this view. You can see the PR here #1339 and discussion here #1340.

One month later and we are still happy with this change, so we think it's appropriate to bring to ViewStore too, which has the same problem.

If anyone wants to share their own experiences with the change, then please do so! We would love to hear more feedback, as we plan on moving from soft deprecated to actually deprecated sometime soon.

@mbrandonw mbrandonw requested a review from stephencelis October 6, 2022 13:36
@tgrapperon
Copy link
Contributor

I'm slightly concerned by the forced hard deprecation of State and Action that will generate warnings for folks who have created helpers/wrappers. If the fixes are pretty straightforward, the change State -> ViewState may look like a non-trivial operation at first sight. It could be worth adding a message: stating that no additional change is required to the deprecation annotation for these typealiases.

@mbrandonw
Copy link
Member Author

True, I suppose we can soft deprecate that too, though we went with hard deprecation for WithViewStore so theoretically someone out there has already come across this.

As far as giving a custom message, I believe the default message is pretty clear:

⚠️ 'State' is deprecated: renamed to 'ViewState'

Is there something else we should be calling out?

@tgrapperon
Copy link
Contributor

My concern is that the (State) -> ViewState is an operation that already exists when dealing with (With)ViewStore, and the renaming from State to ViewState may let think that this operation is performed, or involved in some sort. In other words, that there's more to think about than simply renaming. As the other variants are soft deprecated, it is likely that users will encounter these hard ones first and may suppose that one should now initialize the ViewStore with a Store<ViewState, ViewAction> for example.
I would have imagined something like

⚠️ 'State' is deprecated: renamed to 'ViewState'. This change was performed to avoid the naming collision with the Store<State, Action> that this ViewStore observes.

Of course, written in proper english. I feel that this would make clearer that this operation is merely a naming change, without further implications. But we're in the bike-shedding area, and I'm maybe over-cautious.

@mbrandonw mbrandonw changed the base branch from main to protocol-beta October 9, 2022 21:00
@mbrandonw mbrandonw force-pushed the view-store-observing branch from 1d10d28 to f56c96d Compare October 9, 2022 21:01
@mbrandonw mbrandonw force-pushed the view-store-observing branch from f56c96d to 85b96fd Compare October 9, 2022 21:02
@mbrandonw mbrandonw changed the base branch from protocol-beta to main October 9, 2022 23:12
@mbrandonw mbrandonw merged commit 55755c3 into main Oct 10, 2022
@mbrandonw mbrandonw deleted the view-store-observing branch October 10, 2022 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants