```swift
import SwiftUI
import Amplify
import Combine

/*
 Example showing how to observe the model and keep the state updated before performing a save. This uses the
 `@Published` property for views to observe and re-render changes to the model.
 */
class PostViewModel: ObservableObject {
    @Published var post: Post?
    var subscription: AnyCancellable?
    
    init() {
    }
    
    func observe(postId: String) {
        self.subscription = Amplify.DataStore.observeQuery(for: Post.self,
                                                           where: Post.keys.id == postId).sink { completion in
            print("Completion event: \(completion)")
        } receiveValue: { snapshot in
            guard let post = snapshot.items.first else {
                return
            }
            DispatchQueue.main.async {
                self.post = post
            }
        }
    }
    
    func updateTitle(_ title: String) {
        guard var post = post else {
            return
        }
        post.title = title
        Amplify.DataStore.save(post) { result in
            switch result {
            case .success(let updatedPost):
                print("Updated post successfully: \(updatedPost)")
            case .failure(let error):
                print("Failed to update post: \(error)")
            }
        }
    }
}
struct PostView: View {
    @StateObject var vm = PostViewModel()
    @State private var title = ""
    let postId: String
    
    init(postId: String) {
        self.postId = postId
    }
    
    var body: some View {
        VStack {
            Text("Post's current title: \(vm.post?.title ?? "")")
            TextField("Enter new title", text: $title)
            Button("Click to update the title to '\(title)'") {
                vm.updateTitle(title)
            }
        }.onAppear(perform: {
            vm.observe(postId: postId)
        })
    }
}
```