I recently updated to version ^6.2.0 of the TS SDK. I am trying to understand the best practices for implementing a post feed and liking posts. So far I have been found a combination of the following to work:
For the feed:
- Get post from post repository
PostRepository.getPosts(...
- Subscribe to each post
subscribeTopic(
let unsub = getPostTopic(post, SubscriptionLevels.POST) () => {...
- Observe updates to posts, specifically using the onReactionAdded/Removed callback for likes, and update the state of my component with the returned post from the callback.
const unsub = PostRepository.observePosts(...
Is this the most efficient way to handle realtime updates to likes and the feed in general? It works like this, but the main issue I am seeing is that I am resubscribing to each post after every like, which seems wrong. Thanks!