onClose

fun ByteWriteChannel.onClose(onClose: suspend () -> Unit): ByteWriteChannel

Wraps this channel to execute the provided action when closed using flushAndClose().

Return

A new ByteWriteChannel that executes the given action upon closure.

Parameters

onClose

The action to execute when the channel is closed.