title: SwiftUI - ObservableObject created multiple times
body: <p>I have created an ObservableObject in a View.</p>
  
  <pre><code>@ObservedObject var selectionModel = FilterSelectionModel()
  </code></pre>
  
  <p>I put a breakpoint inside the <code>FilterSelectionModel</code>'s <code>init</code> function and it is called multiple times. Because this View is part of a <code>NavigationLink</code>, I understand that it gets created then and along with it, the selectionModel. When I navigate to the View, the selectionModel is created again. </p>
  
  <p>In this same View I have a "sub View" where I pass the selectionModel as an <code>EnvironmentObject</code> so the sub-view can change it.</p>
  
  <pre><code>AddFilterScreen().environmentObject(self.selectionModel)
  </code></pre>
  
  <p>When the sub view is dismissed, the selectionModel is once more created and the changes made to it have disappeared.</p>
  
  <p><em>Interesting Note</em>: At the very top level is a <code>NavigationView</code>. IF I add </p>
  
  <pre><code>.navigationViewStyle(StackNavigationViewStyle())
  </code></pre>
  
  <p>to this <code>NavigationView</code>, my selectionModel's changes disappear. BUT if I <strong>do not</strong> add the <code>navigationStyle</code>, the selectionModel's changes made in the sub view remain!! (But I don't want a split nav view, I want a stacked nav view)</p>
  
  <p>In both cases - with or without the <code>navigationStyle</code>, the selectionModel is created multiple times. I can't wrap my head around how any of this is supposed to work reliably.</p>