toList

suspend fun <T> Flow<T>.toList(size: Int): List<T>

Collects the specified number of items size from the Flow into a List.

Return

A List of collected items, with a maximum size of size.

Parameters

size

The maximum number of items to collect.


suspend fun <T> Flow<T>.toList(size: Int, duration: Duration): List<T>

Collects the specified number of items size from the Flow into a List within the given duration.

Return

A List of collected items, with a maximum size of size.

Parameters

size

The maximum number of items to collect.

duration

The maximum duration allowed for collecting items.


suspend fun <T> Flow<T>.toList(duration: Duration): List<T>

Collects the items from the Flow into a List within the given duration.

Return

A List of collected items.

Parameters

duration

The maximum duration allowed for collecting items.