Class: StateLookup

StateLookup(opts)

new StateLookup(opts)

Construct a new state lookup entity. This component stores state events for specific event types which can be queried at a later date. This component will perform network requests to fetch the current state for a given room ID. It relies on StateLookup#onEvent being called with later events in order to stay up-to-date. This should be connected to the onEvent handler on the Bridge.
Parameters:
Name Type Description
opts Object Options for this constructor
Properties
Name Type Description
client MatrixClient Required. The client which will perform /state requests.
eventTypes Array.<string> The state event types to track.
Source:
Throws:
if there is no client.

Methods

getState(roomId, eventType, stateKeyopt) → {Object|Array.<Object>}

Get a stored state event.
Parameters:
Name Type Attributes Description
roomId string
eventType string
stateKey string <optional>
If specified, this function will return either the event or null. If not specified, this function will always return an array of events, which may be empty.
Source:
Returns:
Type
Object | Array.<Object>

(async) onEvent(event)

Update any state dictionaries with this event. If there is nothing tracking this room, nothing is stored.
Parameters:
Name Type Description
event Object Raw matrix event
Source:

trackRoom(roomId) → {Promise}

Track a given room. The client must have access to this room. This will perform a room state query initially. Subsequent calls will do nothing, as it will rely on events being pushed to it via StateLookup#onEvent.
Parameters:
Name Type Description
roomId string The room ID to start tracking. You can track multiple rooms by calling this function multiple times with different room IDs.
Source:
Returns:
Resolves when the room is being tracked. Rejects if the room cannot be tracked.
Type
Promise

untrackRoom(roomId)

Stop tracking a given room. This will stop further tracking of state events in the given room and delete existing stored state for it.
Parameters:
Name Type Description
roomId string The room ID to stop tracking.
Source: