A topic is a distinct path that must be constructed for each model to which you wish to subscribe in real-time. The SDK provides helper methods to create these topics for each model type. Each topic encompasses an events enum, which developers can select to subscribe to based on their business context and interests.
To subscribe to updates from a community or any content created within that community, the user must have the 'Member' status in that community. Once the user leaves the community, they will no longer receive real-time events.
Community Topic
COMMUNITY - subscription to changes of the community object
POSTS - subscription to changes of post objects in the community
COMMENTS - subscription to changes of comment objects in the community
POST and COMMENTS - subscription to changes of post and comment objects in the community
The default value is COMMUNITY
import { getCommunityTopic, SubscriptionLevels } from'@amityco/js-sdk';// Community topic to subscribe to all events of that community model only// Example events: community joined, community left, community updated consttopic=getCommunityTopic(communityModel,SubscriptionLevels.COMMUNTIY);// Community topic to subscribe to all post events of that community model// Example events: post created, post deleted, post updatedconsttopic=getCommunityTopic(communityModel,SubscriptionLevels.POST);// Community topic to subscribe to all comment events of that community model// Example events: comment created, comment deleted, comment updatedconsttopic=getCommunityTopic(communityModel,SubscriptionLevels.COMMENT);// Community topic to subscribe to all posts and comment events of that community model// Example events: comment created, comment deleted, comment updatedconsttopic=getCommunityTopic(communityModel,SubscriptionLevels.POST_AND_COMMENT);
The functionality isn't currently supported by this SDK.
Post Topic
POST - subscription to changes of the post object
COMMENTS - subscription to changes of comment objects on the post
The default value is POST
import { getPostTopic, SubscriptionLevels } from'@amityco/js-sdk';// Post topic to subscribe to all events of that post model only// Example events: post edited, reactions added consttopic=getPostTopic(postModel,SubscriptionLevels.POST);// Post topic to subscribe to all comment events of that post model// Example events: comment created, comment deleted, comment updatedconsttopic=getPostTopic(postModel,SubscriptionLevels.COMMENT);
The functionality isn't currently supported by this SDK.
Comment Topic
COMMENT - subscription to changes of the comment object
import { getCommentTopic, SubscriptionLevels } from'@amityco/js-sdk';// Comment topic to subscribe to all comment events of that post model// Example events: comment created, comment deleted, comment updatedconsttopic=getCommentTopic(commentModel,SubscriptionLevels.COMMENT);
The functionality isn't currently supported by this SDK.
User Topic
USER - subscription to changes of the user object
POSTS - subscription to changes of post objects in the user feed
COMMENTS - subscription to changes of comment objects in the user feed
POST and COMMENTS - subscription to changes of post and comment objects in the user feed
The default value is USER
import { getUserTopic, SubscriptionLevels } from'@amityco/js-sdk';// User topic to subscribe to all events of that user model onlyconsttopic=getUserTopic(userModel,SubscriptionLevels.USER);// User topic to subscribe to all post events of that user model// Example events: post created, post deleted, post updatedconsttopic=getUserTopic(userModel,SubscriptionLevels.POST);// User topic to subscribe to all comment events of that user model// Example events: comment created, comment deleted, comment updatedconsttopic=getUserTopic(userModel,SubscriptionLevels.COMMENT);// User topic to subscribe to all posts and comment events of that user model// Example events: comment created, comment deleted, comment updatedconsttopic=getUserTopic(userModel,SubscriptionLevels.POST_AND_COMMENT);
The functionality isn't currently supported by this SDK.
Follow Topic
MY_FOLLOWERS - subscription to changes related users that current user follows
MY_FOLLOWING - subscription to changes related users that follows current user
The functionality isn't currently supported by this SDK.