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 '@river-build/react-sdk'

Examples

import { useTimeline } from '@river-build/react-sdk'
import { RiverTimelineEvent } from '@river-build/sdk'

const { data: events } = useTimeline(streamId)

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

Definition

function useTimeline(
  streamId: string,
  config?: ObservableConfig.FromObservable<TimelineEvents>,
): {
    data: TimelineEvent[];
    error: undefined;
    status: "loading" | "loaded";
    isLoading: boolean;
    isError: false;
    isLoaded: boolean;
}

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.

{
    data: TimelineEvent[];
    error: undefined;
    status: "loading" | "loaded";
    isLoading: boolean;
    isError: false;
    isLoaded: boolean;
}