Skip to content

Instantly share code, notes, and snippets.

@amythee
Last active April 3, 2022 16:23
Show Gist options
  • Save amythee/f03ed67be2640b28b6d07d916ed50b9d to your computer and use it in GitHub Desktop.
Save amythee/f03ed67be2640b28b6d07d916ed50b9d to your computer and use it in GitHub Desktop.
ASC Sample Code
import { PostRepository, getPostTopic, SubscriptionLevels } from '@amityco/js-sdk';
let postModel = {};
const livePost = PostRepository.postForId('abc');
livePost.on('dataUpdated', model => {
postModel = model;
// Post topic to subscribe to all events of that post model only
// Example events: post edited, reactions added
const postTopic = getPostTopic(postModel, SubscriptionLevels.POST);
console.log('Post topic', postTopic);
// Post topic to subscribe to all comment events of that post model
// Example events: comment created, comment deleted, comment updated
const postCommentsTopic = getPostTopic(postModel, SubscriptionLevels.COMMENT);
console.log('Post Comments Topic', postCommentsTopic);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment