cancellable

fun <T> Flow<T>.cancellable(): Flow<T> (source)

Returns a flow which checks cancellation status on each emission and throws the corresponding cancellation cause if flow collector was cancelled. Note that flow builder and all implementations of SharedFlow are cancellable by default.

This operator provides a shortcut for .onEach { currentCoroutineContext().ensureActive() }. See ensureActive for details.

fun <T> SharedFlow<T>.cancellable(): Flow<T> (source)

Deprecated: DeprecationLevel.ERROR

Applying cancellable to a SharedFlow has no effect. See the SharedFlow documentation on Operator Fusion.