Yesterday I spent my entire 8-hour plane trip learning SwiftUI.
Mixed feelings.
It really is fun! Some things are better than I imagined.
Some are worse.
Why does Swift have 3.5 different reactivity frameworks!? Combine, Observation, SwiftUI views, and SwiftUI's deprecated ObservableObject. Each has a different concept of "reacting to an object's value changing”.
And none support async. Combine’s docs actually suggest using AsyncStream instead sometimes, so that's a 5th “framework”.
=> More informations about this toot | More toots from comex@mas.to
Also. I thought the whole point of SwiftUI's function-builder language magic was that it could partially re-evaluate view bodies.
So if you have a view with several controls depending on different inputs, and only one input changes, it would only re-evaluate the parts that depend on that input.
Or if you have a ForEach, it would only re-evaluate the iterations that changed.
But no. Any view will be evaluated entirely or not at all. Subview bodies can then be skipped if they compare equal.
=> More informations about this toot | More toots from comex@mas.to
(At least, this is true as far as I can tell, without seeing the source code.)
=> More informations about this toot | More toots from comex@mas.to
@comex view bodies are fully re-evaluated each time, because they are just procedural code, and Swift has no magic way to determine which parts to skip.
So if the Views returned by body after reevaluation haven't changed, the update is a no-op.
=> More informations about this toot | More toots from nicklockwood@mastodon.social
@comex ForEach is a particularly good example of this. ForEach is not a procedural for loop, it's a struct that models a range over which a template should be applied.
When you return a ForEach of 10000 views, it doesn't iterate 10000 times and produce 10000 views, it just returns a single ForEach struct and then diffs it with the previous one to see if any of the actual views in that range need to be updated.
If they do, it will then run the ForEach's body once for each of those views.
=> More informations about this toot | More toots from nicklockwood@mastodon.social This content has been proxied by September (3851b).Proxy Information
text/gemini