title: How to update a view during a CADisplayLink animation
body: <p>I'm trying to implement a simple animation using <code>CADisplayLink</code>. A black square should move slowly across the screen.</p>
  <p>But the square appears stationary because the <code>body</code> of <code>Squares</code> doesn't get updated when <code>step()</code> increments testX and testY.</p>
  <p>From what I can gather (I'm new to Swift), I'm using the <code>@ObservedObject</code> paradigm correctly, so I don't understand why the view won't refresh.</p>
  <p>How do I get <code>Squares</code>'s <code>body</code> to update along with the animation?</p>
  <p>My code is below, thanks for your help!</p>
  <pre><code>class MyAnimations: NSObject, ObservableObject {
      @Published var testX: Double = 0
      @Published var testY: Double = 0
      
      func createDisplayLink() {
          let displaylink = CADisplayLink(target: self, selector: #selector(step))
          
          displaylink.add(to: .current, forMode: RunLoop.Mode.default)
      }
           
      @objc func step(link: CADisplayLink) {
          testX += 0.5
          testY += 0.5
      }
      
  }
  
  
  
  struct Squares: View {
      @ObservedObject var animation = MyAnimations()
      
      var body: some View {
          Path { path in
              path.addRect(CGRect(x: self.animation.testX, y: self.animation.testY, width: 50, height: 50))
          }
              .fill(Color.black)
      }
  }
  
  
  struct SomeOtherView: View {
      var body: some View {
          Squares()
      }
  }
  </code></pre>