collect

inline suspend fun <T> MaybeSource<T>.collect(action: (T) -> Unit)(source)

Subscribes to this MaybeSource and performs the specified action for each received element.

If action throws an exception at some point or if the MaybeSource raises an error, the exception is rethrown from collect.


inline suspend fun <T> ObservableSource<T>.collect(action: (T) -> Unit)(source)

Subscribes to this ObservableSource and performs the specified action for each received element.

If action throws an exception at some point, the subscription is cancelled, and the exception is rethrown from collect. Also, if the ObservableSource signals an error, that error is rethrown from collect.