getLastTimelineEvents

open override fun getLastTimelineEvents(roomId: RoomId, decryptionTimeout: Duration, fetchTimeout: Duration, limitPerFetch: Long): Flow<Flow<Flow<TimelineEvent?>>?>

Returns the last timeline events as flow.

To convert it to a list, toFlowList can be used or e.g. the events can be consumed manually:

launch {
matrixClient.room.getLastTimelineEvents(roomId).collectLatest { timelineEventsFlow ->
timelineEventsFlow?.take(10)?.toList()?.reversed()?.forEach { println(it) }
}
}

The manual approach needs proper understanding of how flows work. For example: if the client is offline and there are 5 timeline events in store, but take(10) is used, then toList() will suspend.