FeedClient reference
Complete reference for the FeedClient in the Knock JavaScript SDK.
Represents the connection between a user and a feed, including methods for interacting with the items on that feed. Also includes a stateful store that can be used to build in-app notification experiences easily. See FeedStoreState
for more on the shape of the store.
Properties#
store
#Returns: StoreApi<FeedStoreState>
Methods#
listenForUpdates
#Connects the feed instance to the realtime socket so that any new items published to the feed are received over the websocket.
Returns: void
Example:
on
#Binds an event handler to be invoked when the event is triggered.
Events:
Parameters:
Returns: void
.
Example:
off
#Unbinds an existing event handler previously bound with on
. Use this method to cleanup bound event handlers.
Returns: void
.
getState
#Programmatically access the current FeedStoreState
.
Returns: FeedStoreState
.
markAllAsSeen
#Marks all of the items in the store optimistically as seen and performs a server-side request to mark all items on the feed in the current scope as seen. Broadcasts a items:all_seen
event.
Please note: this operation is deferred and may take some time to process all items in the feed.
Returns: Promise<ApiResponse>
markAsSeen
#Marks the given items as seen
. Will perform the operation optimistically, including updating the current metadata
in the FeedStoreState
.
Parameters:
Returns: Promise<ApiResponse>
markAsUnseen
#Removes the seen
status on the item or items given. Will perform the operation optimistically, including updating the current metadata
in the FeedStoreState
.
Parameters:
Returns: Promise<ApiResponse>
markAllAsRead
#Marks all of the items in the store optimistically as read and performs a server-side request to mark all items on the feed in the current scope as read. Broadcasts a items:all_read
event.
Please note: this operation is deferred and may take some time to process all items in the feed.
Returns: Promise<ApiResponse>
markAsRead
#Sets the read
status on the item or items given. Will perform the operation optimistically, including updating the current metadata
in the FeedStoreState
.
Parameters:
Returns: Promise<ApiResponse>
markAsUnread
#Removes the read
status on the item or items given. Will perform the operation optimistically, including updating the current metadata
in the FeedStoreState
.
Parameters:
Returns: Promise<ApiResponse>
markAllAsArchived
#Marks all of the items in the store optimistically as archived and performs a server-side request to mark all items on the feed in the current scope as archived. Broadcasts a items:all_archived
event.
Please note: this operation is deferred and may take some time to process all items in the feed.
Returns: Promise<ApiResponse>
markAsArchived
#Sets the archived
status on the item or items given. Will perform the operation optimistically, including updating the current metadata
in the FeedStoreState
. Broadcasts a items:archived
event.
Parameters:
Returns: Promise<ApiResponse>
markAsUnarchived
#Removes the archived
status on the item or items given. Will perform the operation optimistically, including updating the current metadata
in the FeedStoreState
.
Parameters:
Returns: Promise<ApiResponse>
markAsInteracted
#Sets the interacted
status on the item or items given. Will perform the operation optimistically, including updating the current metadata
in the FeedStoreState
. Broadcasts an items:interacted
event.
Parameters:
Returns: Promise<ApiResponse>
fetch
#Fetches items from the feed.
Emits items.received.page
events on a successful fetch.
Parameters:
Returns: Promise<ApiResponse>
fetchNextPage
#Fetches the next page of the feed items (if there are any more to fetch).
Emits items.received.page
events on a successful fetch.
Note: this will apply any current feed filters and append returned items to the end of the current set of items.