Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

2
  • That works! Brilliant – I totally thought I'd tried that and found it didn't work (it only updated the the final state so changed, but only used one animation). Thank you. … would you be able to extend your answer to explain why the other approaches don't work – either do nothing, or only update with the final state? Commented Jan 3, 2021 at 22:00
  • 1
    I haven't analyzed your other approaches in depth, but you should remember that a view is just a structure and SwiftUI can duplicate it and reinitialize however many times it wants, so a subscription done in init could happen for some copy of TestView - not the one in the view hierarchy. Values have to be assigned to a @State property after init (or directly with self._prop). Commented Jan 3, 2021 at 22:21