Skip to content

Instantly share code, notes, and snippets.

@amythee
Last active April 3, 2022 16:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amythee/ec9c913d8219878556b29cbd3123d82e to your computer and use it in GitHub Desktop.
Save amythee/ec9c913d8219878556b29cbd3123d82e to your computer and use it in GitHub Desktop.
ASC Sample Code
import { UserRepository, getUserTopic, SubscriptionLevels } from '@amityco/js-sdk';
let userModel = {};
const liveUser = UserRepository.userForId('abc');
liveUser.on('dataUpdated', model => {
userModel = model;
// User topic to subscribe to all events of that user model only
const userTopic = getUserTopic(userModel, SubscriptionLevels.USER);
console.log('User topic', userTopic);
// User topic to subscribe to all post events of that user model
// Example events: post created, post deleted, post updated
const userPostTopic = getUserTopic(userModel, SubscriptionLevels.POST);
console.log('User post topic', userPostTopic);
// User topic to subscribe to all comment events of that user model
// Example events: comment created, comment deleted, comment updated
const userCommentsTopic = getUserTopic(userModel, SubscriptionLevels.COMMENT);
console.log('User comments topic', userCommentsTopic);
// User topic to subscribe to all posts and comment events of that user model
// Example events: comment created, comment deleted, comment updated
const userPostsAndCommentsTopic = getUserTopic(userModel, SubscriptionLevels.POST_AND_COMMENT);
console.log('User posts and comments topic', userPostsAndCommentsTopic);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment