How to update one View when another view changed object property?

Good (morning, evening...).
I try to build SwiftUI view hierarchy for model where:

I have many Glyph objects:
  • var manager: CoordinatesManager

  • var elements: [ ManyMultidimensionalElements ]

  • var path: Path { return Path(..based on elements and manager.currentCoordinates) }

I have one CoordinatesManger:
  • var currentCoordinates: [ Coordinate ]

In one view I can set currrentCoordinates of CoordinatesManager, in second view I want to see Glyph with actual glyph.manager.currentCoordinates

It almost works but:
  • changing manager.currentCoordinates doesn't change GlyphView, even if Glyph object see manager.currentCoordinates was changed (in manger.didSet{...})

  • When scrolling (why?) glyph.path is recalculated, but View stays untouched.


How to push View to redraw? Something like NSView.needsDisplay. How to trigger View to redraw, when glyph.manager.currentCoordinates are changed?

PS. It's my first post on this forum, I don't know what's the best: hide Playground file as attachment or list it in main text.
SwiftUI is quite different from the way UIKit works.

There are some fundamental concepts in SwiftUI,
  • Every piece of data is either a Source of truth or a Derived value.

  • When a view access a piece of data, it has a dependancy on this data.

  • There are multiple ways to observe changes to a source of truth, like ObserveredObject, EnvironmentObject, StateObject, State

I feel it would be best if you go through the SwiftUI videos they explain things in detail.
Refer:
https://developer.apple.com/videos/play/wwdc2020/10119
https://developer.apple.com/videos/play/wwdc2020/10040

Also watch the combine videos from 2019 on Apple Developer portal.

It might take a little time to watch them and understand, but well worth it if you are going to work on SwiftUI



How to update one View when another view changed object property?
 
 
Q