Michael Long
Mar 8, 2021

--

Interesting idea, but also not a good one. For the long answer as to why not, see: https://medium.com/swlh/deep-inside-views-state-and-performance-in-swiftui-d23a3a44b79

For a short anwer, SwiftUI views are lighweight, non-heap-allocated definitions of views. Not views. They are constantly being created and regenerated as your application responds to events and redraws the interface, and you're now creating an expensive heap-based publisher and subscription each and every time that happens.

--

--

Michael Long
Michael Long

Written by Michael Long

I write about Apple, Swift, and SwiftUI in particular, and technology in general. I'm also a Lead iOS Engineer at InRhythm, a modern digital consulting firm.

No responses yet