Adding on, its also a bit much to say that Swift has a good level of sugar and reference an enum of all things. Swift's union type story is so poor that, instead of properly modeling state, people to this day still use masses of optional types in their views rather than an enum because actually using swift enums and protocols is so painful.
frizlab|29 days ago
willtemperley|29 days ago
So lots of optionals might well be the better path here.
nielsbot|29 days ago
Let me do this:
Instead of There's an existing proposal for this here:https://forums.swift.org/t/re-proposal-type-only-unions/7270...
Mond_|29 days ago
To understand the difference, `String | String` is just `String`. It's a union, not a sum type. There's no tag or identifier, so you cannot distinguish whether it's the first or the second string.
If this sounds pedantic, this has pretty important ramifications, especially once generics get involved.
kibwen|29 days ago
vor_|28 days ago
In what way? My understanding is they're widely used and encouraged.
JackYoustra|28 days ago
If you actually try and write it all out (like go full-on and use TCA to model all the states and actions such that all and only valid states can be represented in the state types) the compiler is going to have a hard time, you're going to write masses of boilerplate, and just in general it's much rougher than zustand and expo.