Check exhaustivity at build time for SwitchStore
?
#1184
tgrapperon
started this conversation in
General
Replies: 1 comment 1 reply
-
Stephen and I did consider this once upon time (and even considered it again with our recent The primary reason is that it's weird to get access to the state in the case. It may lead you to believe that the closure will be called with the freshest state anytime it changes, but that's not really the case. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The following refers to the branch I've published for reference. As it is not intended to be PR, I'm starting as a discussion.
I wonder why we don't use this variant of
SwitchStore
that would allow exhaustivity at build time? Maybe it was already discussed in some episode on pointfree.co, but I'm not really sure how far the discussion went, and I can't find the episode back.There are of course a few issues:
KeyPath
for enums some day, we could rely on that to conveniently switch over1.case .route: CaseLet(state: /.route, action:…
is a little awkward.switch
in@ViewBuilder
in SwiftUI on iOS 13. I remember some limitations with the@functionBuilder
, but I'm not sure exactly which ones.Such approach would allow to write very natural and exhaustive switches, and would also allow to deprecate, and then remove all the runtime overloads at some point.
Footnotes
This is maybe a possible use-case to add to a certain pitch somewhere… ↩
Beta Was this translation helpful? Give feedback.
All reactions