Hello amity !
steps
1- open two tabs on browser
2- add new post inside the first tab
3- subscribe to live object like this this.liveFeed.on(‘dataUpdated’)
problem
the new post added successfully to the tab that i add the post from
and the live event work with this tab but the other tab not updated the new post that is created with the other tab
expected
need to make live object that detect any change with any other device to make post real time updated
please help me to solve these issue
i use == ionic vue js
and version == “@amityco/js-sdk”: “^5.6.0”
Hello @mohamedismael after the investigation, it appears that in some features you are required to subscribe to the real-time event, please see the sample steps below:
You need to get a topic of real-time event from this example ASC Sample Code
Add the topic from #1 to EventSubscriberReposity same as the example ASC Sample Code
After #1 and #2 real-time event service will send an event to the client automatically (*.on('dataUpdated') will work as expected, please see sample code here ASC Sample Code )
Note: Please don’t forget to do unsubscribe when user proceed to change the page or when real-time events are not required
thank you for your response it works for me
but need one thing
how to subscribe to all posts include timeline and community posts
i call PostRepository.queryAllPosts()
that retrieve all timeline posts includes posts inside community
how to subscribe to this ?
@SocialPlus_Support
i know what you mean but i don`t know what is the appropriate topic need to use
i test all but get error
can you please send me am example to subscribe on PostRepository.queryAllPosts()
that i need it to get All posts includes timeline , community and user follow posts
thank you
There are 2 types of posts: user posts and community posts. If user posts a post in the community it’s a community posts, other way it is user post. Community posts appear in community feeds, user posts in user feeds.
To receive post updates for the user you should do:
import {
UserRepository,
getUserTopic,
SubscriptionLevels,
EventSubscriberRepository,
} from '@amityco/js-sdk';
let user;
const liveUser = UserRepository.userForId('abc');
liveUser.on('dataUpdated', model => {
user = model;
});
// once you have user model you can subscribe to the topic to receive updates for all posts appeared in the user feed
const topic = getUserTopic(user, SubscriptionLevels.POST);
EventSubscriberRepository.subscribe(topic);
The queryAllPosts gives you back a mix of posts from different user feed and community feeds. To be notified that some post is created in general you should subscribe by hand for every user and community you want receive updates from.
For you case, I suppose it’s enough to subscribe to