-
-
Save amythee/ec9c913d8219878556b29cbd3123d82e to your computer and use it in GitHub Desktop.
ASC Sample Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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