Module latest_events

Source
Expand description

The Latest Events API provides a lazy, reactive and efficient way to compute the latest event for a room or a thread.

The latest event represents the last displayable and relevant event a room or a thread has been received. It is usually displayed in a summary, e.g. below the room title in a room list.

The entry point is LatestEvents. It is preferable to get a reference to it from Client::latest_events, which already plugs everything to build it. LatestEvents is using the EventCache and the SendQueue to respectively get known remote events (i.e. synced from the server), or local events (i.e. ones being sent).

§Laziness

LatestEvents is lazy, it means that, despite LatestEvents is listening to all EventCache or SendQueue updates, it will only do something if one is expected to get the latest event for a particular room or a particular thread. Concretely, it means that until LatestEvents::listen_to_room is called for a particular room, no latest event will ever be computed for that room (and similarly with LatestEvents::listen_to_thread).

If one is no longer interested to get the latest event for a particular room or thread, the LatestEvents::forget_room and LatestEvents::forget_thread methods must be used.

§Reactive

LatestEvents is designed to be reactive. Using LatestEvents::listen_and_subscribe_to_room will provide a Subscriber, which brings all the tooling to get the current value or the future values with a stream.

Structs§

LatestEvents
The entry point to fetch the LatestEventValue for rooms or threads.
LocalLatestEventValue
Represents the value for LatestEventValue::LocalIsSending and LatestEventValue::LocalCannotBeSent.

Enums§

LatestEventValue
A latest event value!
LatestEventsError
Errors for the LatestEvents.

Type Aliases§

RemoteLatestEventValue
Represents the value for LatestEventValue::Remote.