Hacker News new | past | comments | ask | show | jobs | submit login

That’s more of a compatibility solution than an escape hatch. An official SwiftUI escape hatch should have access to the underlying imperative object, call methods on it, etc… Unfortunately the underlying ‘things’ in SwiftUI is implementation detail, inspecting the view hierarchy and finding the UIViews that implement a SwiftUI view is a hack.



As I understand it, what you’re asking for is fundamentally incompatible with the paradigm itself (at least in a clean way).

The whole programming experience of declarative UIs is predicated on the fact that you’re manipulating lightweight structs (really just state representations) that are rendered into heavyweight views by the system only where necessary (determined by diffing the state changes).

React’s refs are an attempted answer to this very problem, and they get nasty fast.


> you’re manipulating lightweight structs that are rendered into heavyweight views by the system

Yes, and I’m arguing that not exposing the ‘heavyweight views’ to the programmers at all is a mistake.


Yup, and my understanding of the problem is that if you expose the heavy weight views to the state layer (structs) and allow direct manipulation, render calls lose incompetency, the structs are no longer the source of state truth and the whole abstraction gets terribly leaky.

Edit: once again I think it’s important to look at the limitations and advantages of prior work in this area and I believe React refs to be a good case study in that.


Oops autocomplete. Incompetency should be idempotency.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: