I come from a `react-native` background and I am having trouble understanding a specific part of MVVM in SwiftUI: having multiple views of the same entities.

I am building a simple social media app with posts. These posts can be viewed on the `Homepage`, and on the `Profile` page of any user.

This is what the view models look like

```swift
struct HomepagePosts: ObservableObject {
  @Published var posts = [Post]()

  ... rest of logic
}

struct ProfilePosts: ObservableObject {
  @Published var posts = [Post]()

  ... rest of logic
}

```

My problem is the following. If a user just posted a post, that post will show up on the homepage and on his profile. What if the user decides to update the post? How will the post be updated in all places?

In React this is done by normalizing state. Instead of keeping separate `posts` arrays, you keep 2 arrays of `postId`s, and one dictionary with the `postId` as key and the entire `Post` object as the value. That way, updating the post updates it in one place, and every view updates directly.

How do you do this in SwiftUI?