@827db45f yes, we realized... you're not the only one to ask for this. Unfortunately, we don't have a quick way of doing this currently, but hopefully some time in the future.
@dbc45806 the lifecycle of the coordinator is tied to the lifecycle of the swiftui view (and so is the uiview). Setting parent copies all the properties from the swiftui view to the coordinator, as these might have changed.
@cbccdfde haha, nice. My moment like that is with Transatlanticism. I saw them live a few times, the first time was in 2006 (I think) in Amsterdam. I think they even played the smaller hall. So many good memories.
I updated the view representable blog post to better explain what happens when multiple events are enqueued (e.g. in the text editor case). Now with diagrams as well! https://chris.eidhof.nl/post/view-representable/
@d432c4d9 I think in theory, the bindings might change. So in updateView I *think* you need to at least set them (that's what I do with the parent setting). I'm not 100% sure though.
@d432c4d9 I think in theory, the bindings might change. So in updateView I *think* you need to at least set them (that's what I do with the parent setting). I'm not 100% sure though.
@d432c4d9 so after thinking more about this (and experimenting) it turns out that these updates are actually not spaced out. They all get enqueued straight after each other, and the view is only re-rendered after they're all processed. I updated the post. Thanks for suggesting this!
I wrote a new article about UIViewRepresentable. I came up with two rules for working with them: make all updates from UIKit -> SwiftUI async, and only update what's really needed when setting UIKit properties. If anyone has more feedback I'd love to hear it. https://chris.eidhof.nl/post/view-representable/
@0c13b2e9 I have one of those and used it, great tip! I don’t think I’d have swam across without the buoy. I mean, if I had had others swim or paddle with me I don’t think I would have been so anxious.
We live very close to the lake, and today I finally dared to swim across (alone). I managed not to panic but almost did lose my watch (had to change from freestyle to breaststroke once it got loose). In the end, it took less than ten minutes to swim the 450m or so. My goal for next year is to do this while staying relaxed 😅.
https://objc.s3proxy.de/media_attachments/files/111/024/801/373/662/523/original/e39a00dfa641bb97.png
My next goal for understanding SwiftUI is to *really* understand UIViewRepresentable. If you have examples of stuff you can't get to work, I'd love to hear about it. I'm trying to come up with some rules and patterns so that we don't have to have all kinds of ad-hoc weird hacks to make representables work. I will write this up once I have the feeling I understand it well enough :)
Notes by Chris Eidhof | export