Social Realtime Events
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 in the community objectPOSTS- subscription to changes of post objects in the communityCOMMENTS- subscription to changes of comment objects in the communityPOST and COMMENTS- subscription to changes of posts and posts comments in the communitySTORY and COMMENTS- subscription to changes of story and story comments 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
const topic = getCommunityTopic(communityModel, SubscriptionLevels.COMMUNTIY);
// Community topic to subscribe to all post events of that community model
// Example events: post created, post deleted, post updated
const topic = getCommunityTopic(communityModel, SubscriptionLevels.POST);
// Community topic to subscribe to all comment events of that community model
// Example events: comment created, comment deleted, comment updated
const topic = 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 updated
const topic = getCommunityTopic(communityModel, SubscriptionLevels.POST_AND_COMMENT);Post Topic
POST- subscription to changes of the post objectCOMMENTS- 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
const topic = getPostTopic(postModel, SubscriptionLevels.POST);
// Post topic to subscribe to all comment events of that post model
// Example events: comment created, comment deleted, comment updated
const topic = getPostTopic(postModel, SubscriptionLevels.COMMENT);Comment Topic
COMMENT- subscription to changes in 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 updated
const topic = getCommentTopic(commentModel, SubscriptionLevels.COMMENT);The functionality isn't currently supported by this SDK.
User Topic
USER- subscription to changes in the user objectPOSTS- subscription to changes of post objects in the user feedCOMMENTS- subscription to changes of comment objects in the user feedPOST 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 only
const topic = getUserTopic(userModel, SubscriptionLevels.USER);
// User topic to subscribe to all post events of that user model
// Example events: post created, post deleted, post updated
const topic = getUserTopic(userModel, SubscriptionLevels.POST);
// User topic to subscribe to all comment events of that user model
// Example events: comment created, comment deleted, comment updated
const topic = 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 updated
const topic = getUserTopic(userModel, SubscriptionLevels.POST_AND_COMMENT);The functionality isn't currently supported by this SDK.
Follow Topic
MY_FOLLOWERS- subscription to changes related to users that the current user followsMY_FOLLOWING- subscription to changes related to users that follow current user
The functionality isn't currently supported by this SDK.
STORY Topic
Subscription to changes related to specific stories.
Last updated
Was this helpful?