EventTimeline
Defined in: src/models/event-timeline.ts:50
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”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.
Parameters
Section titled “Parameters”eventTimelineSet
Section titled “eventTimelineSet”the set of timelines this is part of
Returns
Section titled “Returns”EventTimeline
Properties
Section titled “Properties”paginationRequests
Section titled “paginationRequests”paginationRequests:
Record<Direction,Promise<boolean> |null>
Defined in: src/models/event-timeline.ts:88
BACKWARDS
Section titled “BACKWARDS”
readonlystaticBACKWARDS: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.
FORWARDS
Section titled “FORWARDS”
readonlystaticFORWARDS: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.
Methods
Section titled “Methods”addEvent()
Section titled “addEvent()”addEvent(
event,options):void
Defined in: src/models/event-timeline.ts:348
Add a new event to the timeline, and update the state
Parameters
Section titled “Parameters”new event
options
Section titled “options”addEvent options
Returns
Section titled “Returns”void
fork()
Section titled “fork()”fork(
direction):EventTimeline
Defined in: src/models/event-timeline.ts:179
Creates an independent timeline, inheriting the directional state from this timeline.
Parameters
Section titled “Parameters”direction
Section titled “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.
Returns
Section titled “Returns”EventTimeline
the new timeline
forkLive()
Section titled “forkLive()”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.
Parameters
Section titled “Parameters”direction
Section titled “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.
Returns
Section titled “Returns”EventTimeline
the new timeline
getBaseIndex()
Section titled “getBaseIndex()”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).
Returns
Section titled “Returns”number
getEvents()
Section titled “getEvents()”getEvents():
DigitalWorldEvent[]
Defined in: src/models/event-timeline.ts:229
Get the list of events in this context
Returns
Section titled “Returns”An array of DigitalWorldEvents
getFilter()
Section titled “getFilter()”getFilter():
Filter|undefined
Defined in: src/models/event-timeline.ts:199
Get the filter for this timeline’s timelineSet (if any)
Returns
Section titled “Returns”Filter | undefined
filter
getNeighbouringTimeline()
Section titled “getNeighbouringTimeline()”getNeighbouringTimeline(
direction):EventTimeline|null
Defined in: src/models/event-timeline.ts:299
Get the next timeline in the series
Parameters
Section titled “Parameters”direction
Section titled “direction”EventTimeline.BACKWARDS to get the previous timeline; EventTimeline.FORWARDS to get the next timeline.
Returns
Section titled “Returns”EventTimeline | null
previous or following timeline, if they have been joined up.
getPaginationToken()
Section titled “getPaginationToken()”getPaginationToken(
direction):string|null
Defined in: src/models/event-timeline.ts:261
Get a pagination token
Parameters
Section titled “Parameters”direction
Section titled “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.
Returns
Section titled “Returns”string | null
pagination token
getRoomId()
Section titled “getRoomId()”getRoomId():
string|null
Defined in: src/models/event-timeline.ts:191
Get the ID of the room for this timeline
Returns
Section titled “Returns”string | null
room ID
getState()
Section titled “getState()”getState(
direction):RoomState|undefined
Defined in: src/models/event-timeline.ts:242
Get the room state at the start/end of the timeline
Parameters
Section titled “Parameters”direction
Section titled “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.
Returns
Section titled “Returns”RoomState | undefined
state at the start/end of the timeline
getTimelineSet()
Section titled “getTimelineSet()”getTimelineSet():
EventTimelineSet
Defined in: src/models/event-timeline.ts:207
Get the timelineSet for this timeline
Returns
Section titled “Returns”timelineSet
initialiseState()
Section titled “initialiseState()”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.
Parameters
Section titled “Parameters”stateEvents
Section titled “stateEvents”list of state events to initialise the state with.
__namedParameters?
Section titled “__namedParameters?”Returns
Section titled “Returns”void
Throws
Section titled “Throws”Error if an attempt is made to call this after addEvent is called.
removeEvent()
Section titled “removeEvent()”removeEvent(
eventId):DigitalWorldEvent|null
Defined in: src/models/event-timeline.ts:439
Remove an event from the timeline
Parameters
Section titled “Parameters”eventId
Section titled “eventId”string
ID of event to be removed
Returns
Section titled “Returns”DigitalWorldEvent | null
removed event, or null if not found
setNeighbouringTimeline()
Section titled “setNeighbouringTimeline()”setNeighbouringTimeline(
neighbour,direction):void
Defined in: src/models/event-timeline.ts:320
Set the next timeline in the series
Parameters
Section titled “Parameters”neighbour
Section titled “neighbour”EventTimeline
previous/following timeline
direction
Section titled “direction”EventTimeline.BACKWARDS to set the previous timeline; EventTimeline.FORWARDS to set the next timeline.
Returns
Section titled “Returns”void
Throws
Section titled “Throws”Error if an attempt is made to set the neighbouring timeline when it is already set.
setPaginationToken()
Section titled “setPaginationToken()”setPaginationToken(
token,direction):void
Defined in: src/models/event-timeline.ts:280
Set a pagination token
Parameters
Section titled “Parameters”string | null
pagination token
direction
Section titled “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.
Returns
Section titled “Returns”void
toString()
Section titled “toString()”toString():
string
Defined in: src/models/event-timeline.ts:458
Return a string to identify this timeline, for debugging
Returns
Section titled “Returns”string
name for this timeline
setEventMetadata()
Section titled “setEventMetadata()”
staticsetEventMetadata(event,stateContext,toStartOfTimeline):void
Defined in: src/models/event-timeline.ts:70
Static helper method to set sender and target properties
Parameters
Section titled “Parameters”the event whose metadata is to be set
stateContext
Section titled “stateContext”the room state to be queried
toStartOfTimeline
Section titled “toStartOfTimeline”boolean
if true the event’s forwardLooking flag is set false
Returns
Section titled “Returns”void