title: UI changes with ObservableObject just after switching tabs
body: <p>I have a <code>ObservableObject</code> that I use to update my UI when new data is sent from the server (an a class which contains an array of custom structs).</p>
  
  <p>For some reason, when the data is sent, the <code>ContentView</code>'s <code>body</code> is called, but the data isn't changed. I even added a <code>print</code> statement to check if the data that the array contains is right and it is.</p>
  
  <p>When I try to switch to another tab on my <code>TabView</code>, and then switch back to the main view, the UI <strong>does</strong> get updated. Does anybody know why the UI updates just when I switch tabs, although the <code>body</code> gets recalled to update the UI when the data changed?</p>
  
  <p><strong>HomeView</strong></p>
  
  <pre><code>struct HomeView: View {
      @ObservedObject private var fbData = firebaseData
  
      var body: some View {
          TabView {
              //Home Tab
              NavigationView {
                  ScrollView(showsIndicators: false) {
                      ForEach(self.fbData.posts.indices, id: \.self) { postIndex in
                          PostView(post: self.$fbData.posts[postIndex])
                              .listRowInsets(EdgeInsets())
                              .padding(.vertical, 5)
                      }
                  }
                  .navigationBarTitle("MyPhotoApp", displayMode: .inline)
                  .navigationBarItems(leading:
                      Button(action: {
                          print("Camera btn pressed")
                      }, label: {
                          Image(systemName: "camera")
                              .font(.title)
                      })
                  , trailing:
                      Button(action: {
                          print("Messages btn pressed")
                      }, label: {
                          Image(systemName: "paperplane")
                              .font(.title)
                      })
                  )
              } . tabItem({
                  Image(systemName: "house")
                      .font(.title)
              })
  
              Text("Search").tabItem {
                  Image(systemName: "magnifyingglass")
                      .font(.title)
              }
  
              Text("Upload").tabItem {
                  Image(systemName: "plus.app")
                      .font(.title)
              }
  
              Text("Activity").tabItem {
                  Image(systemName: "heart")
                      .font(.title)
              }
  
              Text("Profile").tabItem {
                  Image(systemName: "person")
                      .font(.title)
              }
          }
          .accentColor(.black)
          .edgesIgnoringSafeArea(.top)
      }
  }
  </code></pre>
  
  <p><strong>FirebaseData</strong>:</p>
  
  <pre><code>class FirebaseData : ObservableObject {
      @Published var posts = [Post]()
  
      let postsCollection = Firestore.firestore().collection("Posts")
  
      init() {
          self.fetchPosts()
      }
  
      //MARK: Fetch Data
      private func fetchPosts() {
          self.postsCollection.addSnapshotListener { (documentSnapshot, err) in
              if err != nil {
                  print("Error fetching posts: \(err!.localizedDescription)")
                  return
              } else {
                  documentSnapshot!.documentChanges.forEach { diff in
                      if diff.type == .added {
                          let post = self.createPostFromDocument(document: diff.document)
                          self.posts.append(post)
                      } else if diff.type == .modified {
                          self.posts = self.posts.map { (post) -&gt; Post in
                              if post.id == diff.document.documentID {
                                  return self.createPostFromDocument(document: diff.document)
                              } else {
                                  return post
                              }
                          }
                      } else if diff.type == .removed {
                          for index in self.posts.indices {
                              if self.posts[index].id == diff.document.documentID {
                                  self.posts.remove(at: index)
                              }
                          }
                      }
                  }
              }
          }
      }
  </code></pre>