React Native TS SDK Best Practices for liking posts on a feed

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:

  1. Get post from post repository
  1. Subscribe to each post
let unsub = getPostTopic(post, SubscriptionLevels.POST) () => {...
  1. 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!

Hey @joee,

If you are using version 6.x.x and above you no longer need to call observe as the SDK listens to all events pertaining to a domain.

You can check the docs as to which topics you need to subscribe for receiving RTE. As for post based on the targetType you can subscribe to just the community or user topic.

Let me know if you have further question :slight_smile:

1 Like