Skip to content

EventTimeline

Defined in: src/models/event-timeline.ts:50

new EventTimeline(eventTimelineSet): EventTimeline

Defined in: src/models/event-timeline.ts:112

Construct a new EventTimeline

An EventTimeline represents a contiguous sequence of events in a room.

As well as keeping track of the events themselves, it stores the state of the room at the beginning and end of the timeline, and pagination tokens for going backwards and forwards in the timeline.

In order that clients can meaningfully maintain an index into a timeline, the EventTimeline object tracks a 'baseIndex'. This starts at zero, but is incremented when events are prepended to the timeline. The index of an event relative to baseIndex therefore remains constant.

Once a timeline joins up with its neighbour, they are linked together into a doubly-linked list.

EventTimelineSet

the set of timelines this is part of

EventTimeline

paginationRequests: Record<Direction, Promise<boolean> | null>

Defined in: src/models/event-timeline.ts:88


readonly static BACKWARDS: Backward = Direction.Backward

Defined in: src/models/event-timeline.ts:55

Symbolic constant for methods which take a ‘direction’ argument: refers to the start of the timeline, or backwards in time.


readonly static FORWARDS: Forward = Direction.Forward

Defined in: src/models/event-timeline.ts:61

Symbolic constant for methods which take a ‘direction’ argument: refers to the end of the timeline, or forwards in time.

addEvent(event, options): void

Defined in: src/models/event-timeline.ts:348

Add a new event to the timeline, and update the state

DigitalWorldEvent

new event

IAddEventOptions

addEvent options

void


fork(direction): EventTimeline

Defined in: src/models/event-timeline.ts:179

Creates an independent timeline, inheriting the directional state from this timeline.

Direction

EventTimeline.BACKWARDS to get the state at the start of the timeline; EventTimeline.FORWARDS to get the state at the end of the timeline.

EventTimeline

the new timeline


forkLive(direction): EventTimeline

Defined in: src/models/event-timeline.ts:155

Forks the (live) timeline, taking ownership of the existing directional state of this timeline. All attached listeners will keep receiving state updates from the new live timeline state. The end state of this timeline gets replaced with an independent copy of the current RoomState, and will need a new pagination token if it ever needs to paginate forwards.

Direction

EventTimeline.BACKWARDS to get the state at the start of the timeline; EventTimeline.FORWARDS to get the state at the end of the timeline.

EventTimeline

the new timeline


getBaseIndex(): number

Defined in: src/models/event-timeline.ts:220

Get the base index.

This is an index which is incremented when events are prepended to the timeline. An individual event therefore stays at the same index in the array relative to the base index (although note that a given event's index may well be less than the base index, thus giving that event a negative relative index).

number


getEvents(): DigitalWorldEvent[]

Defined in: src/models/event-timeline.ts:229

Get the list of events in this context

DigitalWorldEvent[]

An array of DigitalWorldEvents


getFilter(): Filter | undefined

Defined in: src/models/event-timeline.ts:199

Get the filter for this timeline’s timelineSet (if any)

Filter | undefined

filter


getNeighbouringTimeline(direction): EventTimeline | null

Defined in: src/models/event-timeline.ts:299

Get the next timeline in the series

Direction

EventTimeline.BACKWARDS to get the previous timeline; EventTimeline.FORWARDS to get the next timeline.

EventTimeline | null

previous or following timeline, if they have been joined up.


getPaginationToken(direction): string | null

Defined in: src/models/event-timeline.ts:261

Get a pagination token

Direction

EventTimeline.BACKWARDS to get the pagination token for going backwards in time; EventTimeline.FORWARDS to get the pagination token for going forwards in time.

string | null

pagination token


getRoomId(): string | null

Defined in: src/models/event-timeline.ts:191

Get the ID of the room for this timeline

string | null

room ID


getState(direction): RoomState | undefined

Defined in: src/models/event-timeline.ts:242

Get the room state at the start/end of the timeline

Direction

EventTimeline.BACKWARDS to get the state at the start of the timeline; EventTimeline.FORWARDS to get the state at the end of the timeline.

RoomState | undefined

state at the start/end of the timeline


getTimelineSet(): EventTimelineSet

Defined in: src/models/event-timeline.ts:207

Get the timelineSet for this timeline

EventTimelineSet

timelineSet


initialiseState(stateEvents, __namedParameters?): void

Defined in: src/models/event-timeline.ts:134

Initialise the start and end state with the given events

This can only be called before any events are added.

DigitalWorldEvent[]

list of state events to initialise the state with.

IInitialiseStateOptions = {}

void

Error if an attempt is made to call this after addEvent is called.


removeEvent(eventId): DigitalWorldEvent | null

Defined in: src/models/event-timeline.ts:439

Remove an event from the timeline

string

ID of event to be removed

DigitalWorldEvent | null

removed event, or null if not found


setNeighbouringTimeline(neighbour, direction): void

Defined in: src/models/event-timeline.ts:320

Set the next timeline in the series

EventTimeline

previous/following timeline

Direction

EventTimeline.BACKWARDS to set the previous timeline; EventTimeline.FORWARDS to set the next timeline.

void

Error if an attempt is made to set the neighbouring timeline when it is already set.


setPaginationToken(token, direction): void

Defined in: src/models/event-timeline.ts:280

Set a pagination token

string | null

pagination token

Direction

EventTimeline.BACKWARDS to set the pagination token for going backwards in time; EventTimeline.FORWARDS to set the pagination token for going forwards in time.

void


toString(): string

Defined in: src/models/event-timeline.ts:458

Return a string to identify this timeline, for debugging

string

name for this timeline


static setEventMetadata(event, stateContext, toStartOfTimeline): void

Defined in: src/models/event-timeline.ts:70

Static helper method to set sender and target properties

DigitalWorldEvent

the event whose metadata is to be set

RoomState

the room state to be queried

boolean

if true the event’s forwardLooking flag is set false

void