Hook to get the timeline events from a stream.

You can use the useTimeline hook to get the timeline events from a channel stream, dm stream or group dm stream

Imports

import { useTimeline } from '@towns-protocol/react-sdk'

Examples

import { useTimeline } from '@towns-protocol/react-sdk'
import { RiverTimelineEvent } from '@towns-protocol/sdk'

const { data: events } = useTimeline(streamId)

// You can filter the events by their kind
const messages = events.filter((event) => event.content?.kind === RiverTimelineEvent.ChannelMessage)

Definition

function useTimeline(
  streamId: string,
  config?: ObservableConfig.FromObservable<TimelineEvents>,
): ObservableValue<TimelineEvent[]>

Source: useTimeline

Parameters

streamId

  • Type: string

The id of the stream to get the timeline events from.

config

  • Type: ObservableConfig.FromObservable<TimelineEvents>
  • Optional

Configuration options for the observable.

Return Type

The timeline events of the stream as an observable.

ObservableValue<TimelineEvent[]>