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 NameDescriptionWhere is it published?
Activity Events
ActivityAddedEventFired when a new activity is added to a feedclient, feed
ActivityUpdatedEventFired when an activity is modifiedclient, feed
ActivityDeletedEventFired when an activity is removedclient, feed
ActivityRemovedFromFeedEventFired when an activity is removed from a specific feedclient, feed
ActivityMarkEventFired when activities are marked as read/seenclient, feed
ActivityPinnedEventFired when an activity is pinned to the topclient, feed
ActivityUnpinnedEventFired when an activity is unpinnedclient, feed
Comment Events
CommentAddedEventFired when a new comment is added to an activityclient, feed
CommentUpdatedEventFired when a comment is modifiedclient, feed
CommentDeletedEventFired when a comment is removedclient, feed
Reaction Events
ActivityReactionAddedEventFired when a reaction is added to an activityclient, feed
ActivityReactionDeletedEventFired when a reaction is removed from an activityclient, feed
CommentReactionAddedEventFired when a reaction is added to a commentclient, feed
CommentReactionDeletedEventFired when a reaction is removed from a commentclient, feed
Poll Events
PollClosedFeedEventFired when a poll is closedclient
PollDeletedFeedEventFired when a poll is deletedclient
PollUpdatedFeedEventFired when a poll is modifiedclient
PollVoteCastedFeedEventFired when a vote is castclient
PollVoteChangedFeedEventFired when a vote is changedclient
PollVoteRemovedFeedEventFired when a vote is removedclient
Feed Events
FeedCreatedEventFired when a new feed is createdclient, feed
FeedUpdatedEventFired when a feed is modifiedclient, feed
FeedDeletedEventFired when a feed is deletedclient, feed
FeedGroupChangedEventFired when a feed group is modifiedclient, feed
FeedGroupDeletedEventFired when a feed group is deletedclient, feed
Member Events
FeedMemberAddedEventFired when a member is added to a feedclient, feed
FeedMemberRemovedEventFired when a member is removed from a feedclient, feed
FeedMemberUpdatedEventFired when a member’s role/permissions changeclient, feed
Follow Events
FollowCreatedEventFired when a follow relationship is createdclient, feed
FollowDeletedEventFired when a follow relationship is removedclient, feed
FollowUpdatedEventFired when follow settings are modifiedclient, feed
Bookmark Events
BookmarkAddedEventFired when an activity is bookmarkedclient
BookmarkDeletedEventFired when a bookmark is removedclient
BookmarkUpdatedEventFired when bookmark metadata is modifiedclient
Connection Events
ConnectedEventFired when successfully connected to WebSocketclient
ConnectionErrorEventFired when connection fails or errors occurclient
HealthCheckEventFired when health check is receivedclient
ConnectionChangedEventFired when the client changes between being offline or onlineclient

Feed events

Feed events are related to a specific feed. This is how you can subscribe to them:

// 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));

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"}`),
);
© Getstream.io, Inc. All Rights Reserved.