title: How to listen to an ObservableObject
body: <p>Ok, so <code>SwiftUI</code> and <code>ObservableObject</code>, on iOS 13.  I have <code>Model</code> that implements <code>ObservableObject</code>:</p>
  <pre><code>class Model: ObservableObject {
      @Published public var toggle: Bool = false
  
      init() {
          NSLog(&quot;Model init&quot;)
          objectWillChange.sink { void in
              NSLog(&quot;1 toggle \(self.toggle)&quot;)
          }
          $toggle.sink { v in
              NSLog(&quot;2 toggle \(self.toggle) -&gt; \(v)&quot;)
          }
      }
  }
  </code></pre>
  <p>and a Button that toggles <code>toggle</code>:</p>
  <pre><code>struct ContentView: View {
      @ObservedObject var model: Model
      
      var body: some View {
          Button(action: {
              self.model.toggle.toggle()
          }, label: {Text(model.toggle ? &quot;on&quot; : &quot;off&quot;)})
      }
  }
  </code></pre>
  <p>Now, this works.  You hit the button and it toggles between &quot;on&quot; and &quot;off&quot;.  (Before making <code>toggle</code> <code>@Published</code>, it did not.)  However, the logging does not work as expected.  I get two logs immediately on startup: &quot;Model init&quot; and &quot;2 toggle false -&gt; false&quot;.  Tapping the button, though apparently changing the value of <code>toggle</code>, does not cause either of the closures to execute.</p>
  <p>When the view mutates your model, I'd expect there to be a way to be informed of the change, in case you need to e.g. update calculated values or sync to disk or something.  Perhaps <code>sink</code> is the wrong method?</p>
  <p>How can an <code>ObservableObject</code> with <code>@Published</code> fields be notified when its fields are updated?</p>