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§
- Latest
Events - The entry point to fetch the
LatestEventValuefor rooms or threads. - Local
Latest Event Value - Represents the value for
LatestEventValue::LocalIsSendingandLatestEventValue::LocalCannotBeSent.
Enums§
- Latest
Event Value - A latest event value!
- Latest
Events Error - Errors for the
LatestEvents.
Type Aliases§
- Remote
Latest Event Value - Represents the value for
LatestEventValue::Remote.