```swift
// In your type declaration, declare a cancellable to hold onto the subscription
var postsSubscription: AnyCancellable?

func subscribeToPosts() {
    let post = Post.keys
    self.postsSubscription = Amplify.DataStore.observeQuery(
            for: Post.self,
            where: post.title.beginsWith("post") && post.rating > 10.0,
            sort: .ascending(post.rating)
        )
        .sink { completed in
            switch completed {
            case .finished:
                print("finished")
            case .failure(let error):
                print("Error \(error)")
            }
        } receiveValue: { querySnapshot in
            print("[Snapshot] item count: \(querySnapshot.items.count), isSynced: \(querySnapshot.isSynced)")
        }
}

// Then, when you're finished observing, cancel the subscription
func unsubscribeFromPosts() {
    postsSubscription?.cancel()
}
```