// Watch for a specific event
const unsubscribe = feed.on("feeds.activity.added", (event) =>
console.log(event),
);
// Watch for all events
const unsubscribe = feed.on("all", (event) => console.log(event));
Activity Feeds V3 is in closed alpha — do not use it in production (just yet).
Event Handling
The state layer provides a way to be notified about state updates easily. However, it’s also possible to watch for WebSocket events directly, should you need it.
Available Event Types
Below is a comprehensive table of all available event types and their descriptions:
Event Name | Description | Where is it published? |
---|---|---|
Activity Events | ||
ActivityAddedEvent | Fired when a new activity is added to a feed | client , feed |
ActivityUpdatedEvent | Fired when an activity is modified | client , feed |
ActivityDeletedEvent | Fired when an activity is removed | client , feed |
ActivityRemovedFromFeedEvent | Fired when an activity is removed from a specific feed | client , feed |
ActivityMarkEvent | Fired when activities are marked as read/seen | client , feed |
ActivityPinnedEvent | Fired when an activity is pinned to the top | client , feed |
ActivityUnpinnedEvent | Fired when an activity is unpinned | client , feed |
Comment Events | ||
CommentAddedEvent | Fired when a new comment is added to an activity | client , feed |
CommentUpdatedEvent | Fired when a comment is modified | client , feed |
CommentDeletedEvent | Fired when a comment is removed | client , feed |
Reaction Events | ||
ActivityReactionAddedEvent | Fired when a reaction is added to an activity | client , feed |
ActivityReactionDeletedEvent | Fired when a reaction is removed from an activity | client , feed |
CommentReactionAddedEvent | Fired when a reaction is added to a comment | client , feed |
CommentReactionDeletedEvent | Fired when a reaction is removed from a comment | client , feed |
Poll Events | ||
PollClosedFeedEvent | Fired when a poll is closed | client |
PollDeletedFeedEvent | Fired when a poll is deleted | client |
PollUpdatedFeedEvent | Fired when a poll is modified | client |
PollVoteCastedFeedEvent | Fired when a vote is cast | client |
PollVoteChangedFeedEvent | Fired when a vote is changed | client |
PollVoteRemovedFeedEvent | Fired when a vote is removed | client |
Feed Events | ||
FeedCreatedEvent | Fired when a new feed is created | client , feed |
FeedUpdatedEvent | Fired when a feed is modified | client , feed |
FeedDeletedEvent | Fired when a feed is deleted | client , feed |
FeedGroupChangedEvent | Fired when a feed group is modified | client , feed |
FeedGroupDeletedEvent | Fired when a feed group is deleted | client , feed |
Member Events | ||
FeedMemberAddedEvent | Fired when a member is added to a feed | client , feed |
FeedMemberRemovedEvent | Fired when a member is removed from a feed | client , feed |
FeedMemberUpdatedEvent | Fired when a member’s role/permissions change | client , feed |
Follow Events | ||
FollowCreatedEvent | Fired when a follow relationship is created | client , feed |
FollowDeletedEvent | Fired when a follow relationship is removed | client , feed |
FollowUpdatedEvent | Fired when follow settings are modified | client , feed |
Bookmark Events | ||
BookmarkAddedEvent | Fired when an activity is bookmarked | client |
BookmarkDeletedEvent | Fired when a bookmark is removed | client |
BookmarkUpdatedEvent | Fired when bookmark metadata is modified | client |
Connection Events | ||
ConnectedEvent | Fired when successfully connected to WebSocket | client |
ConnectionErrorEvent | Fired when connection fails or errors occur | client |
HealthCheckEvent | Fired when health check is received | client |
ConnectionChangedEvent | Fired when the client changes between being offline or online | client |
Feed events
Feed events are related to a specific feed. This is how you can subscribe to them:
To receive feed event, you need to watch the feed:
const feed = client.feed("user", "sara");
// Provide the watch flag to receive state updates via WebSocket events
await feed.getOrCreate({ watch: true });
// Query multiple feeds using a filter
const feeds = client.queryFeeds({
filter: {
// Your query
},
// Provide the watch flag to receive state updates via WebSocket events
watch: true,
});
Client events
Client events contain
- all events related to currently watched feeds
- all poll vote events related to currently watched feeds
- events related to a specific user (for example bookmark event)
- events related to network connection
// Watch for a specific event
const unsubscribe = client.on("connection.changed", (event) =>
console.log(event),
);
// Watch for all events
const unsubscribe = client.on("all", (event) =>
console.log(`Client is ${event.online ? "online" : "offline"}`),
);
On this page: